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

当前回答

对我来说,所有建议的方法都不起作用——使用cert、HTTP、trusted-host。

在我的例子中,切换到不同版本的包是可行的(在本例中是paho-mqtt 1.3.1,而不是paho-mqtt 1.3.0)。

看来问题只针对那个版本。

其他回答

你可以试着忽略“https”:

pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org  [your package..]

为了一劳永逸地解决这个问题,您可以验证您有一个pip.conf文件。

根据文档,这是你的pip.conf应该在的地方:

在Unix上,默认的配置文件是:$HOME/.config/pip/pip.conf,它尊重XDG_CONFIG_HOME环境变量。 在macOS上,如果$HOME/Library/Application Support/pip目录存在,则配置文件为$HOME/.config/pip/pip.conf 在Windows上,配置文件是%APPDATA%\pip\pip.ini。

在virtualenv内部:

在Unix和macOS上,文件是$VIRTUAL_ENV/pip.conf 在Windows上,文件是:%VIRTUAL_ENV%\pip.ini

你的pip.conf应该是这样的:

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

pip install linkchecker在我创建pip.conf文件后安装linkchecker,没有抱怨。

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

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

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

到现在为止,当pip升级到10,现在他们已经把路径从pypi.python.org更改为files.pythonhosted.org 请将命令更新为pip——trusted-host files.pythonhosted.org install python_package