urllib.request 模块无法安装到我的系统中
urllib.request module fails to install in my system
尝试使用以下命令安装 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
如何安装这个模块?
urllib.request 仅在 python3 分支中可用。有关详细信息,请参阅以下 post。 urllib.request in Python 2.7
在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()
在python3中你必须使用urllib3模块。
$ pip3 install urllib3
或者,如果您使用的是虚拟环境:
$ pip install urllib3
对于 Python3 在 cmd 中,
pip install urllib3
或者如果您使用的是蟒蛇:
conda install urllib3
希望这对您有所帮助
对于未来 reader(我相信其中大多数是 python3 用户),urllib 已经在 Python3 上可用,只需 import urllib
到您的代码即可。
尝试使用以下命令安装 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
如何安装这个模块?
urllib.request 仅在 python3 分支中可用。有关详细信息,请参阅以下 post。 urllib.request in Python 2.7
在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()
在python3中你必须使用urllib3模块。
$ pip3 install urllib3
或者,如果您使用的是虚拟环境:
$ pip install urllib3
对于 Python3 在 cmd 中,
pip install urllib3
或者如果您使用的是蟒蛇:
conda install urllib3
希望这对您有所帮助
对于未来 reader(我相信其中大多数是 python3 用户),urllib 已经在 Python3 上可用,只需 import urllib
到您的代码即可。