问题
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?
回答1:
urllib.request is only available in python3 branch. See the following post for more info. urllib.request in Python 2.7
回答2:
In python3 you must use urllib3 module.
$ pip3 install urllib3
Or if you're using a virtual env:
$ pip install urllib3
回答3:
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()
回答4:
For Python3 in cmd,
pip install urllib3
Or if you're using a anaconda:
conda install urllib3
Hope, this will help you
来源:https://stackoverflow.com/questions/29382709/urllib-request-module-fails-to-install-in-my-system