urllib.request module fails to install in my system

ぃ、小莉子 提交于 2021-02-07 05:13:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!