问题描述
我很难使用 pip 安装几乎所有东西.我是编码新手,所以我想这可能是我做错了,并选择了 easy_install 来完成我需要完成的大部分工作,这通常有效.但是,现在我正在尝试下载 nltk 库,但都没有完成.
I have a difficult time using pip to install almost anything. I'm new to coding, so I thought maybe this is something I've been doing wrong and have opted out to easy_install to get most of what I needed done, which has generally worked. However, now I'm trying to download the nltk library, and neither is getting the job done.
我尝试进入
sudo pip install nltk
但得到了以下回复:
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May 4 00:15:38 2013
Downloading/unpacking nltk
Getting page https://pypi.python.org/simple/nltk/
Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link]/simple/nltk/ when looking for download links for nltk
Getting page [need more reputation to post link]/simple/
Could not fetch URL https://pypi.python. org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link] when looking for download links for nltk
Cannot fetch index base URL [need more reputation to post link]
URLs to search for versions for nltk:
* [need more reputation to post link]
Getting page [need more reputation to post link]
Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link] when looking for download links for nltk
Could not find any downloads that satisfy the requirement nltk
No distributions at all found for nltk
Exception information:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1026, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 171, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for nltk
--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it.
对这个问题有什么想法吗?我非常感谢有关如何让 pip 正常工作或同时解决此问题的一些反馈.
Any thoughts on this issue? I'd really appreciate some feedback on how I can either get pip working or something to get around the issue in the meantime.
推荐答案
我发现将 pypi 主机指定为可信主机就足够了.示例:
I found it sufficient to specify the pypi host as trusted. Example:
pip install --trusted-host pypi.python.org pytest-xdist
pip install --trusted-host pypi.python.org --upgrade pip
这解决了以下错误:
Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping
Could not find a version that satisfies the requirement pytest-cov (from versions: )
No matching distribution found for pytest-cov
2018 年 4 月更新:对于收到 TLSV1_ALERT_PROTOCOL_VERSION 错误的任何人:它与 OP 的可信主机/验证问题或此答案无关.而 TLSV1 错误是因为您的解释器不支持 TLS v1.2,您必须升级您的解释器.参见例如 https://news.ycombinator.com/item?id=13539034,http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.html 和 https://bugs.python.org/issue17128.
Update April 2018:To anyone getting the TLSV1_ALERT_PROTOCOL_VERSION error: it has nothing to do with trusted-host/verification issue of the OP or this answer. Rather the TLSV1 error is because your interpreter does not support TLS v1.2, you must upgrade your interpreter. See for example https://news.ycombinator.com/item?id=13539034, http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.html and https://bugs.python.org/issue17128.
2019 年 2 月更新:对于某些人来说,升级 pip 可能就足够了.如果上述错误阻止您这样做,请使用 get-pip.py.例如.在 Linux 上,
Update Feb 2019:For some it may be sufficient to upgrade pip. If the above error prevents you from doing this, use get-pip.py. E.g. on Linux,
curl https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
更多详情请见https://pip.pypa.io/en/stable/installing/.
这篇关于安装几乎所有库的 pip 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!