我对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

当前回答

我通过删除我的pip并安装旧版本的pip来解决这个问题: https://pypi.python.org/pypi/pip/1.2.1

其他回答

使用——cert参数:

您可以使用以下命令指定证书:

pip --cert <path/to/cert>.pem install <package list>

例如:

pip --cert /etc/ssl/certs/FOO_Root_CA.pem install linkchecker

参见:文档»参考指南»pip

如果指定您公司的根证书不起作用,也许cURL证书可以工作:http://curl.haxx.se/ca/cacert.pem

必须使用PEM文件,而不是CRT文件。如果你有一个CRT文件,你将需要将文件转换为PEM。评论中有报告说,这现在与CRT文件一起工作,但我还没有验证。

还要检查:SSL证书验证。

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

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

尽管有40个答案,但我认为没有一个完全解决了我的问题。

我在macOS Catalina 10.15.5上,在公司代理的后面。

在尝试安装或升级包时,提示以下错误

>>> pip install <package name>                                                                                                                           

Looking in indexes: https://pypi.org/simple, https://data:****@pypi.<company>.com/simple/
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': <package name>
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': <package name>

@Steve_Tauber的回答pip——cert /etc/ssl/certs/FOO_Root_CA。Pem安装链接检查器让我的方式有一部分。

我能够使用现有的cert文件成功安装包,如下所示:

pip install --cert /Users/me/opt/anaconda3/ssl/cert.pem --upgrade pip

但是我不想每次使用pip时都使用cert标志…

答案是更新环境变量:

CERT_PATH=/Users/me/opt/anaconda3/ssl/cert.pem
export SSL_CERT_FILE=${CERT_PATH}
export REQUESTS_CA_BUNDLE=${CERT_PATH}

现在我可以安装了。

要使用的答案

pip install --trusted-host pypi.python.org <package>

工作。但你必须检查是否有重定向或缓存pip正在击中。在安装了pip 9.0.1的Windows 7上,我必须运行

pip install \
  --trusted-host pypi.python.org \
  --trusted-host pypi.org \
  --trusted-host files.pythonhosted.org \
  <package>

您可以使用verbose标志找到这些。

这对我来说很管用:

$ sudo mv /etc/ssl/cert.pem /etc/ssl/cert.pem.BAK

在我的情况下,我在安装pip时得到了相同的错误,在尝试运行aws CLI命令时也出现了类似的错误。这一周一切正常,下一周就不正常了。AFAIK,我没有安装任何会破坏SSL的东西。

我在MacOS大苏尔,尝试了不同版本的Python 3。通过pyenv和Brew安装。我尝试了这篇文章中列出的所有相关解决方案。我甚至重新安装了操作系统,但还是不行。