urllib.request module fails to install in my system
Asked Answered
D

5

14

Tried installing urllib.request module using below command

sudo pip install urllib.request

but it returned

Downloading/unpacking urllib.request
  Could not find any downloads that satisfy the requirement urllib.request
Cleaning up...
No distributions at all found for urllib.request
Storing debug log for failure in /home/mounarajan/.pip/pip.log

How can I install this module?

Discuss answered 1/4, 2015 at 4:10 Comment(4)
maybe i'm missing something, but why don't you just install urllib -- i.e., sudo pip install urllib. does that not include request?Atherton
it also throws same errorDiscuss
i'm just throwing darts at the wall here, but what about sudo pip install urllib3? would that get you what you want?Atherton
or perhaps you need to install a version of pip compatible with python 3?Atherton
C
18

urllib.request is only available in python3 branch. See the following post for more info. urllib.request in Python 2.7

Comedic answered 1/4, 2015 at 4:18 Comment(3)
yeah i using python 3Discuss
what do you mean, "python3 filename.py"? what is "filename.py"?Atherton
python3 is verson name and filename is the name of the file in which u save you program in your directory so python3 filename.pyDiscuss
A
8

In python3 you must use urllib3 module.

$ pip3 install urllib3

Or if you're using a virtual env:

$ pip install urllib3
Asepsis answered 4/3, 2018 at 20:53 Comment(0)
P
6

In python 2 ,you simply use urllib for example

import urllib
htmlfile=urllib.urlopen("your url")
htmltext=htmlfile.read()

in python 3,you need to use urllib.request

import urllib.request
htmlfile=urllib.request.urlopen("your url")
htmltext=htmlfile.read()
Pantomime answered 7/3, 2016 at 5:32 Comment(0)
S
3

For Python3 in cmd,

pip install urllib3

Or if you're using a anaconda:

conda install urllib3

Hope, this will help you

Stodder answered 19/2, 2019 at 6:1 Comment(0)
A
0

For future reader (which I believe most of them are python3 users), urllib is already available on Python3 simply import urllib to your code.

Anisaanise answered 9/4, 2022 at 8:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.