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

当前回答

如果您的系统中缺少某些证书,则可能会遇到此问题。在opensuse上安装ca-certificates-mozilla

其他回答

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

一种解决方案(适用于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

希望这能帮助到一些人!

短期解决方案:

easy_install <package name>

例如:

easy_install pandas

替代解决方案:

pip install <package_name> --trusted-host pypi.org --trusted-host files.pythonhosted.org

例子:

pip install pandas --trusted-host pypi.org --trusted-host files.pythonhosted.org

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

简短的回答

如果在家里使用公司的机器时遇到这种情况,在工作时再试一次。

细节

我周末遇到了这个。Pip和conda都坏了,无法安装或更新。SO很有帮助,但在公司机器上,许多答案都有问题——解决方案需要pip install(已经不能工作)或需要下载安装程序(我想下载的安装程序被防火墙设置禁止)。

对我有效的是当我上预科的时候再试一次。这很有效。事实证明,在家庭和工作中使用这台机器时,公司防火墙的设置是不同的。