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

当前回答

我也遇到过类似的问题。对我有效的解决方法 1)卸载python 2.7 2)删除python27文件夹 3)重新安装最新的python

其他回答

我也遇到过类似的问题。对我有效的解决方法 1)卸载python 2.7 2)删除python27文件夹 3)重新安装最新的python

永久解决

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

如:

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

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

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

我尝试使用公司代理,但失败了。

我使用的是Python 3.6。

Pip.conf文件丢失。

下面是解决这个问题的步骤:

安装证书包:-pip——truste- host pypi.python.org——truste- host files.pythonhosted.org——truste- host pypi.org 创建一个pip.conf文件,如下所示:

     $ cd ~/.config 
     $ mkdir pip
     $ cd pip
     $ nano pip.conf

将以下内容添加到新创建的.conf文件中,并保存。

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

一切都完成了,它开始工作了。

如果已经编译了Python,则执行以下操作在Python中启用SSL。

wget --no-check-certificate https://www.python.org/ftp/python/3.9.10/Python-3.9.10.tgz
tar -zxf Python-3.9.10.tgz
cd Python-3.9.10
mkdir /home/$USER/tools
export INSTALL_BASE_PATH=/home/$USER/tools

mkdir -p {INSTALL_BASE_PATH}/ssl
vi ./Modules/Setup      # Modify below lines in this file to these

SSL = {INSTALL_BASE_PATH} / SSL _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto .使用实例

./configure \
    --prefix=${INSTALL_BASE_PATH} \
    --enable-shared \
    --enable-ipv6 \
    LDFLAGS=-Wl,-rpath=${INSTALL_BASE_PATH}/lib,--disable-new-dtags

make
make install