出于某种原因,我在使用 pip 安装新软件包时遇到了问题。我有一个 OS Sierra 环境,之前一切正常。现在无论我是否使用 virtualenv,我都会得到:
Collecting requests
Could not find a version that satisfies the requirement requests (from
versions: )
No matching distribution found for requests
这不仅适用于“请求”库,也适用于所有其他库(例如 django 等)。
我有最新的点子:
pip --version
returns: pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
我的 python 版本是:2.7.12
此外,根据 这篇文章,我检查了我是否可以卷曲 PyPi 网站,我确实得到了回复。
知道有什么问题吗?
已编辑
我将 pip 安装执行为:
pip install -vvv requests
我得到了错误的详细输出:
Collecting requests
2 location(s) to search for versions of requests:
* http://pypi.python.org/simple/requests/
* http://pypi.wfp.org/simple/requests/
Getting page http://pypi.python.org/simple/requests/
Starting new HTTP connection (1): pypi.python.org
"GET /simple/requests/ HTTP/1.1" 403 16
Could not fetch URL http://pypi.python.org/simple/requests/: 403 Client
Error: SSL is required for url: http://pypi.python.org/simple/requests/ -
skipping
Getting page http://pypi.wfp.org/simple/requests/
Starting new HTTP connection (1): pypi.wfp.org
"GET /simple/requests/ HTTP/1.1" 404 None
Could not fetch URL http://pypi.wfp.org/simple/requests/: 404 Client
Error: NOT FOUND for url: http://pypi.wfp.org/simple/requests/ - skipping
Could not find a version that satisfies the requirement requests (from
versions: )
Cleaning up...
No matching distribution found for requests
Exception information:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-
py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-
py2.7.egg/pip/commands/install.py", line 324, in run
requirement_set.prepare_files(finder)
File "/Library/Python/2.7/site-packages/pip-9.0.1-
py2.7.egg/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/Library/Python/2.7/site-packages/pip-9.0.1-
py2.7.egg/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/Library/Python/2.7/site-packages/pip-9.0.1-
py2.7.egg/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/index.py",
line 514, in find_requirement
'No matching distribution found for %s' % req
DistributionNotFound: No matching distribution found for requests
原文由 user1919 发布,翻译遵循 CC BY-SA 4.0 许可协议
感谢@Klaus D. 评论(建议添加:命令中的 -v 标志),我发现 URL 为:
需要改为
执行此命令效果很好:
或者,您可以按照 此处 的答案之一所述更改 pip.conf 文件: