• 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

    • Apple is giving the upcoming iPad Pro a second front-facing camera by Taras Buria The M4-based iPad Pro brought a few significant changes to Apple's high-end tablet, such as tandem OLED displays, a much-thinner chassis, camera changes, and a much more powerful processor. Its successor, the M5-based iPad Pro, is rumored to retain the current form factor without major changes. However, there is one rather odd hardware update that is coming with the next iPad Pro. A new report says that a successor to the current iPad Pro lineup will offer a more powerful Apple M5 processor and more cameras on the front. While Apple experimented with a dual-camera setup on the back of the recent iPad Pros (this was killed in the M4 generation), the front of every iPad has always had a single camera, minus the original one, of course, which had none. With the M5 iPad Pro, Apple is rumored to double the number of front-facing cameras for a rather odd reason. No, Apple is not using a dual-camera setup for depth of field effects or a wider angle. According to Bloomberg's Mark Gurman, the logic is much simpler: satisfy fans of the portrait orientation. The problem is that in the 2024 iPad Pro, Apple moved the front-facing camera to the longer side of the tablet, where it makes much more sense for FaceTime calls, selfies, and everything else. However, that makes the iPad a bit awkward to use when in portrait mode, especially when it comes to FaceID. Now, it appears that Apple wants to make both camps happy by adding another front-facing camera to the shorter side of the screen. There is no information on whether we will see just one more front-facing camera or the entire FaceID module. Given Apple's nature of blaming users for some of its device shortcomings (the infamous "you are holding it wrong" line), it is quite interesting to see Apple addressing a seemingly minor concern with such an overkill solution.
    • Hello! It's default behavior. I assume that F:\ and E:\ are external drives? My local drives are under This PC. So File Explorer is showing storage from different locations: This PC (under which are local drives) Mapped Network drives External USB drives The Network (under which, my NAS) You could drag the drive to Quick access to see it all the time, but in my case when I expand This PC, the local drives remain in view even when I close and reopen the window.
    • It also lost Window Share support, so can no longer share websites from Edge to it or files from Explorer using the Share button or photos from Photos app. Mind you, not that this is impossible from a webappp since the new Outlook does support Share and that's a web app.
    • Was that just a warning about malware in general, or is there a list of malware that's proven to affect a computer outside a sandbox/vm?
    • One of the best file managers for Windows 11 gets brand-new Omnibar and more by Taras Buria Files is a popular file manager for Windows 10 and 11, and it is one of the best alternatives to the stock File Explorer. The app is packed with features, it looks fantastic on Windows 11, it is free, and it regularly receives feature updates. The latest preview update, version 3.9.12, introduces some big changes to the address bar, search, and filtering. With Files Preview 3.9.12, the app is getting the new Omnibar. It is a new control that works the same as your browser's address bar. It combines the "breadcrumb" path and the search box into a single UI element. By default, the new Omnibar displays breadcrumbs, which are the current path to the folder with quick access to each directory in the path and their nested folders. Besides the visual overhaul, the new Omnibar introduces a new Home button with a dedicated flyout that lets you navigate to quick access items, drives, and other elements. You can click the new Omnibar (or press Ctrl + L) to edit or copy the current path, paste a new address or navigate to another folder by typing its location. The Omnibar also now hosts the Command Palette, which you can trigger by pressing Ctrl + Shift + P. With the Omnibar, Files no longer uses a dedicated search bar. You can search for files by pressing Ctrl + F or clicking a search button in the omnibar. It is also worth noting that developers changed how filtering works. Now, Files has a dedicated filter UI instead of defaulting to filtering items when typing in the search box. It works faster and it is more intuitive. Other changes in Files Preview 3.9.12 include OX Drive integration and partial RTL support. You can download Files Preview 3.9.12 from the official Files.community website. If you want to support developers, you can purchase the preview version from the Microsoft Store.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      497
    2. 2
      Michael Scrip
      206
    3. 3
      ATLien_0
      201
    4. 4
      Xenon
      136
    5. 5
      +FloatingFatMan
      117
  • Tell a friend

    Love Neowin? Tell a friend!