我对Python非常陌生,并试图在Windows 7上安装链接检查器。一些注意事项:

pip install is failing no matter the package. For example, > pip install scrapy also results in the SSL error. Vanilla install of Python 3.4.1 included pip 1.5.6. The first thing I tried to do was install linkchecker. Python 2.7 was already installed, it came with ArcGIS. python and pip were not available from the command line until I installed 3.4.1. > pip search linkchecker works. Perhaps that is because pip search does not verify the site's SSL certificate. I am in a company network but we do not go through a proxy to reach the Internet. Each company computer (including mine) has a Trusted Root Certificate Authority that is used for various reasons including enabling monitoring TLS traffic to https://google.com. Not sure if that has anything to do with it.

下面是运行pip install linkchecker后我的pip.log的内容:

Downloading/unpacking linkchecker
  Getting page https://pypi.python.org/simple/linkchecker/
  Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
  Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'http.client.CannotSendRequest'>: Request-sent)
  Will skip URL https://pypi.python.org/simple/ when looking for download links for linkchecker
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for linkchecker:
  * https://pypi.python.org/simple/linkchecker/
  Getting page https://pypi.python.org/simple/linkchecker/
  Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
  Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
  Could not find any downloads that satisfy the requirement linkchecker
Cleaning up...
  Removing temporary dir C:\Users\jcook\AppData\Local\Temp\pip_build_jcook...
No distributions at all found for linkchecker
Exception information:
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python34\lib\site-packages\pip\req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "C:\Python34\lib\site-packages\pip\index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for linkchecker

当前回答

时间和日期设置正确!

对我来说,树莓派上的日期和时间配置错误。结果是使用https://files.pythonhosted.org/服务器的所有SSL和HTTPS连接都失败了。

像这样更新:

sudo date -s "Wed Thu  23 11:12:00 GMT+1 2018"
sudo dpkg-reconfigure tzdata

或者直接与谷歌的时间连用:

Ref。https://superuser.com/a/635024/935136

sudo date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"
sudo dpkg-reconfigure tzdata

其他回答

在64位Windows 7企业版上尝试使用ActivePython 2.7.8、ActivePython 3.4.1和“库存”Python 3.4.2安装pip ftputil时遇到同样的问题。所有尝试都失败了,错误与OP相同。

通过降级到pip 1.2.1来解决Python 3.4.2的问题:easy_install pip==1.2.1(参见https://stackoverflow.com/a/16370731/234235)。同样的修复也适用于ActivePython 2.7.8。

2013年3月报告的这个漏洞仍然存在:https://github.com/pypa/pip/issues/829。

我对pip 21.0.1有这个问题,没有一个答案对我有效。一些人通过降低pip版本来解决这个问题。

如果在2021年你仍然有这个问题,我确实降级到pip 20.2.4,现在它起作用了。

对于Python 3.10

添加/更新文件内容

[global]
trusted-host = pypi.python.org
           pypi.org
           files.pythonhosted.org

文件位置

MacOS - $HOME/Library/Application Support/pip/pip.conf Unix - $HOME/.config/pip/pip.conf Windows - %APPDATA%\pip\pip.ini

一种解决方案(适用于Windows)是在%AppData%\pip\文件夹上创建一个名为pip.ini的文件(如果不存在则创建该文件夹),并插入以下细节:

[global]
cert = C:/certs/python_root.pem
proxy = http://my_user@my_company.com:my_password@proxy_ip:proxy_port

...然后我们可以执行安装指令:

pip3 install PyQt5

另一种选择是使用代理和证书的参数来安装包…

$ pip3 install --proxy http://my_user@my_company.com:my_password@proxy_ip:proxy_port \
   --cert C:/certs/python_root.pem PyQt5

转换证书*。Cer文件到所需的*。Pem格式执行如下指令:

$ openssl x509 -inform der -in python_root.cer -out python_root.pem

希望这能帮助到一些人!

我得到了同样的错误,即使尝试了许多黑客。 所以我去了官方网站(https://pypi.org/project/),在那里我们可以找到特定软件包的车轮文件(.whl)并下载了它。

现在在命令提示符中:

PIP安装path_to_wheel_file/file_name.whl

现在文件已经成功安装。