Python urllib.request 模块无法在我的系统中安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29382709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
urllib.request module fails to install in my system
提问by Mounarajan
Tried installing urllib.request module using below command
尝试使用以下命令安装 urllib.request 模块
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?
如何安装此模块?
采纳答案by Kozyarchuk
urllib.request is only available in python3 branch. See the following post for more info. urllib.request in Python 2.7
urllib.request 仅在 python3 分支中可用。有关更多信息,请参阅以下帖子。 Python 2.7 中的 urllib.request
回答by niharika kumar
In python 2 ,you simply use urllib for example
在 python 2 中,您只需使用 urllib 例如
import urllib
htmlfile=urllib.urlopen("your url")
htmltext=htmlfile.read()
in python 3,you need to use urllib.request
在 python 3 中,你需要使用 urllib.request
import urllib.request
htmlfile=urllib.request.urlopen("your url")
htmltext=htmlfile.read()
回答by Tim Nikitin
In python3 you must use urllib3 module.
在 python3 中,你必须使用 urllib3 模块。
$ pip3 install urllib3
Or if you're using a virtual env:
或者,如果您使用的是虚拟环境:
$ pip install urllib3
回答by Aashish Mamgain
For Python3 in cmd,
对于 cmd 中的 Python3,
pip install urllib3
Or if you're using a anaconda:
或者,如果您使用的是蟒蛇:
conda install urllib3
Hope, this will help you
希望能帮到你