• 0

installing urllib in Python 3.6 fails - confusion with Python 2.7


Question

hello dear Experts,


installing urllib in Python3.7 - here i encountered issues.  I would like to import urllib to use the function 'request'.


However, I encountered an error when trying to do so. I tried pip install urllib but still had the same error. I am using Python 3.7.x Really appreciate any help. i do import urllib.request using this following code:

 

import urllib.request, urllib.parse, urllib.error
fhand = urllib.request.urlopen('data.pr4e.org/romeo.txt')
counts = dict()
for line in fhand:
words = line.decode().split()
for word in words:
counts[word] = counts.get(word, 0) + 1
print(counts) 

 

but it gives me this error: ModuleNotFoundError:
No Module named 'urllib.parse'; 'urllib' is not a package

if i look at this page: https://urllib3.readthedocs.io/en/latest/

they recomend to install this way:

 

pip install urllib3
if i do so i get back this:
root@mx:/home/martin# pip install urllib3
Requirement already satisfied: urllib3 in /usr/lib/python2.7/dist-packages (1.24.1)
root@mx:/home/martin# ^C
root@mx:/home/martin# 

 

well this is funny - since it points out some path to python 2.7

Alternatively, the manpage (https://urllib3.readthedocs.io/en/latest/ ) suggests to go this way: grab the latest source code from GitHub:

 

$ git clone git://github.com/urllib3/urllib3.git
$ python setup.py install

 

this i did not try yet! But i will do so

3 answers to this question

Recommended Posts

  • 0

 

 

by the way: i allways thoguth that urllib is a standard python library (built-in) so you don't have to install it.

just import it if you need to use request by:

 

 

import urllib.request

 

i will do further investigations...

  • 0


finally managed to setup VSCodium on the MX-Linux (Version 19.1)

 

 

Version: 1.43.2
Commit: 0ba0ca52957102ca3527cf479571617f0de6ed50
Date: 2020-03-24T21:03:16.125Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 4.19.0-6-amd64

 

 

guess that this is the actual Version!?!  . again the machine: MX-19.1 with Python 3.7.xy installed

 

Note: at the moment VSCodium is not configured towards a python-development-system. These steps have not been made. 
conclusio: on the mx-linux i now have VSCodium besides ATOM-Editor - i like ATOM it has a nice Github-Integration.

on a sidenote: on the Windows-machine (WIN-10) i have VS-Code Version: 1.43:

see on Win10 i have the following data: 

 

1 Version: 1.43.2 (user setup)
2 Commit: 0ba0ca52957102ca3527cf479571617f0de6ed50
3 Date: 2020-03-24T07:38:38.248Z
4 Electron: 7.1.11
5 Chrome: 78.0.3904.130
6 Node.js: 12.8.1
7 V8: 7.8.279.23-electron.0
8 OS: Windows_NT x64 10.0.18363

 

 

at the moment i struggle with the following message:

 

 

 NodeJS not detected on this machine, which is required for Pymakr to work. See the Pymakr readme for dependancies.


well back to the Linux-machine with MX-Linux version 19.1 and with ATOM. on a freshly installed ATOM on MX-Linux: i have to setup a lot. for some test i run the code - taken from here: https://stackoverflow.com/questions/60908216/how-to-handle-multiple-urls-in-beautifultsoup-and-convert-the-data-into-datafram

see what i have got back bs4_request_10  Link: https://pastebin.com/C3V8vryr

 

 

 

Traceback (most recent call last):
  File "/home/martin/dev/python/daad_studienangebote_url_liste.py", line 25, in <module>
    Main(urls)
  File "/home/martin/dev/python/daad_studienangebote_url_liste.py", line 20, in Main
    df.to_csv("data.csv", index=False)
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/generic.py", line 3020, in to_csv
    formatter.save()
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 172, in save
    self._save()
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 288, in _save
    self._save_chunk(start_i, end_i)
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 315, in _save_chunk
    self.cols, self.writer)
  File "pandas/_libs/writers.pyx", line 75, in pandas._libs.writers.write_csv_rows
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 39: ordinal not in range(128)
[Finished in 3.134s]

 

 

by the way:  see more errors: gathered with bs4 scripts form SO within the last 5 days - runned here:

 

bs4_request_1  Link: https://pastebin.com/sUmva6iJ
bs4_request_2  Link: https://pastebin.com/Tt3XaG4p
bs4_request_3  Link: https://pastebin.com/wf9VTvjs
bs4_request_4  Link: https://pastebin.com/1s6LVqni
bs4_request_6  Link: https://pastebin.com/tEsZxxEs
bs4_request_7  Link: https://pastebin.com/55q4ewrq
bs4_request_8  Link: https://pastebin.com/YNKAMUXH

bs4_request_10  Link: https://pastebin.com/C3V8vryr

 

i guess that i set up the machine /ATOM badly … - any and all help greatly appreciated. - regards Zero


I recently have read an article on using Virtual Environments for Python projects.
https://towardsdatascience.com/python-virtual-environments-made-easy-fe0c603fe601

 

and this one  Comparing Python Virtual Environment tools
https://towardsdatascience.com/comparing-python-virtual-environment-tools-9a6543643a44

 

 

guess that have to take care how i setup python on my linux-machine. 


 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • For anyone looking for a lightweight formatting-free text editor, I recommend Notepad3.
    • This looks really dumb, especially if it costs $100+. Noone who cares about using a flight yoke would touch that thing, people who don't care are probably fine using the analog sticks on their controller, so who is it for?
    • A) "they shouldn't be making money off of those [free videos]"?? That is literally their business model, making money off videos that users post...if you don't feel like that should be allowed, then are you saying YouTube shouldn't exist. B) Yes, the example I gave is a net-negative transaction. If YouTube makes money from others who are following their rules, it doesn't change the fact that the person using an ad-blocker is costing them money. C) YouTube has always operated at a loss...kind of invalidates your entire argument. As I always say, I don't care what you do, I will not even say you are wrong for doing it. That is purely your choice. Just be honest enough to say something like "Google is rich, I honestly don't care." Perfectly fine reason. Don't act like there is some imagined justification for why it isn't breaking the rules.
    • You can now present content from your camera feed in Google Meet by David Uzondu Google has a new feature rolling out for Google Meet that lets you directly present video from an external camera feed right into your meetings. This means if you have a document camera for showing physical papers, a dedicated external camera for a better angle, or even output from a video production tool, you can now pipe that into Meet as a presentation source. This new option supports video up to 1080p at 30FPS. This "present from camera" function offers a more integrated way to handle certain video inputs compared to some existing workarounds. For instance, it might prove less complicated than a setup with OBS Studio where you arrange your various video sources into scenes, activate the virtual camera output, and then navigate Google Meet's settings to specifically choose "OBS Virtual Camera" as your video input before you can even start presenting that customized feed. Alongside this camera presentation feature, Google's announcement also mentioned several improvements to the general screen sharing experience in Meet. Initiating any type of screen share is faster now, and video quality during screen sharing has also been sharpened, with better handling of dynamic content like scrolling text or embedded videos. To reduce interruptions, if a second presenter stops sharing their screen, any previous presentation will now automatically resume. For those wondering when they can get their hands on this, the rollout for the camera presentation feature and these screen sharing enhancements has begun for Rapid Release domains. Users on Scheduled Release domains will start seeing it from June 11, 2025. Google notes that it could take up to 15 days for these features to be visible to all eligible users. Most Google Workspace accounts, including Business Standard and Plus, various Enterprise and Education tiers, and Workspace Individual subscribers, will have access. This new presentation option joins other recent Google Workspace enhancements. For instance, Gemini in Google Drive can now summarize changes to your files, offering a quick way to get updated on what you missed in documents since you last opened them.
  • Recent Achievements

    • First Post
      James courage Tabla earned a badge
      First Post
    • Reacting Well
      James courage Tabla earned a badge
      Reacting Well
    • Apprentice
      DarkShrunken went up a rank
      Apprentice
    • Dedicated
      CHUNWEI earned a badge
      Dedicated
    • Collaborator
      DarkShrunken earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      379
    2. 2
      +FloatingFatMan
      175
    3. 3
      ATLien_0
      169
    4. 4
      snowy owl
      169
    5. 5
      Xenon
      133
  • Tell a friend

    Love Neowin? Tell a friend!