我对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 21.0.1有这个问题,没有一个答案对我有效。一些人通过降低pip版本来解决这个问题。

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

其他回答

你有4个选择:

使用证书作为参数

$ pip install --cert /path/to/mycertificate.crt linkchecker

使用pip.conf中的证书

创建这个文件:

$HOME/.pip/pip.conf (Linux)

%HOME%\pip\pip.ini (Windows)

然后加上这几行:

[global]
cert = /path/to/mycertificate.crt

忽略证书并使用HTTP

$ pip install --trusted-host pypi.python.org linkchecker

忽略证书,在pip.conf中使用HTTP

创建这个文件:

$HOME/.pip/pip.conf (Linux)

%HOME%\pip\pip.ini (Windows)

然后加上这几行:

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

https://pip.pypa.io/en/latest/user_guide/#configuration

在我的情况下,这是由于SSL证书是由我公司的内部CA签署的。使用像pip——cert这样的变通方法并没有帮助,但是下面的包可以:

pip install pip_system_certs

参见:https://pypi.org/project/pip-system-certs/

这个包修补pip并在运行时请求使用来自默认系统存储的证书(而不是捆绑的certs ca)。 这将允许pip验证tls/ssl连接到您的系统安装信任的服务器。

在安装任何其他包之前运行PIP安装证书解决了我的问题

我尝试了这个回答博客中提供的大多数解决方案,但是没有一个有效,我在尝试安装python包时遇到了这个ssl证书错误。

我通过以下命令成功执行:

python -m pip install PACKAGENAME --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org 

对我来说,创建一个文件夹就解决了这个问题 Pip,有一个文件:Pip .ini 在 C:\Users\ <用户名> \ AppData \ \徘徊 例句:

C:\Users\<username>\AppData\Roaming\pip\pip.ini

我在信里写道:

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

我重新启动python,然后pip永久信任这些站点,并使用它们下载包。

如果你在windows上找不到AppData文件夹,在文件资源管理器中写入% AppData %,它就会出现。