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

当前回答

这对我来说很管用:

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

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

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

其他回答

修复了我在OSX上的问题,在终端上运行以下程序:

open "/Applications/Python 3.9/Install Certificates.command"

沃斯坦的回答帮助了我。

我在我的电脑上找不到pip.ini文件。接下来的事情也是如此。

进入AppData文件夹。您可以通过打开命令提示符并输入echo % appdata %来获取appdata文件夹

或者在windows资源管理器中输入%AppData%。

在appdata文件夹中创建一个名为pip的文件夹。 在刚才创建的pip文件夹中,创建一个名为pip.ini的简单文本文件 使用您选择的简单编辑器在该文件中执行以下配置设置。

pip.ini文件:

[list]
format=columns

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

现在应该可以开始了。

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

如果您使用make手动安装Python,则必须遵循以下答案:https://stackoverflow.com/a/42798679/6403406以使其工作。

您可以尝试使用http而不是https来绕过SSL错误。当然,这在安全性方面并不是最优的,但如果你赶时间,它应该可以做到:

pip install --index-url=http://pypi.python.org/simple/ linkchecker