urllib.request模块无法在我的系统中安装

时间:2015-04-01 04:10:50

标签: python ubuntu pip urllib sudo

尝试使用以下命令安装urllib.request模块

sudo pip install urllib.request

但它返回了

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

如何安装此模块?

4 个答案:

答案 0 :(得分:14)

urllib.request仅在python3分支中可用。有关详细信息,请参阅以下帖子。 urllib.request in Python 2.7

答案 1 :(得分:7)

在python3中,你必须使用urllib3模块。

$ pip3 install urllib3

或者,如果您使用的是虚拟环境:

$ pip install urllib3

答案 2 :(得分:6)

在python 2中,你只需使用urllib 例如

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

在python 3中,你需要使用urllib.request

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

答案 3 :(得分:0)

对于cmd中的Python3,

pip install urllib3

或者如果您正在使用水蟒:

conda install urllib3

希望,这对您有帮助