在使用pip安装时会输出错误信息

在使用pip安装软件包时出现错误。

Python的版本是“Python 3.6.5”。

$ pip install django-oscar
Collecting django-oscar
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /packages/4d/32/d84c3fbbb4dd85edb6f2f49c0e91f4bfb25523207a998e3d6f2e4b4e80ee/django_oscar-1.6.4-py2.py3-none-any.whl
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /packages/4d/32/d84c3fbbb4dd85edb6f2f49c0e91f4bfb25523207a998e3d6f2e4b4e80ee/django_oscar-1.6.4-py2.py3-none-any.whl
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /packages/4d/32/d84c3fbbb4dd85edb6f2f49c0e91f4bfb25523207a998e3d6f2e4b4e80ee/django_oscar-1.6.4-py2.py3-none-any.whl
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /packages/4d/32/d84c3fbbb4dd85edb6f2f49c0e91f4bfb25523207a998e3d6f2e4b4e80ee/django_oscar-1.6.4-py2.py3-none-any.whl
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /packages/4d/32/d84c3fbbb4dd85edb6f2f49c0e91f4bfb25523207a998e3d6f2e4b4e80ee/django_oscar-1.6.4-py2.py3-none-any.whl
Exception:
Traceback (most recent call last):
  File "/home/kafka/venv/oscar/lib64/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/kafka/venv/oscar/lib64/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/home/kafka/venv/oscar/lib64/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/home/kafka/venv/oscar/lib64/python3.6/site-packages/pip/_vendor/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/home/kafka/venv/oscar/lib64/python3.6/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib64/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib64/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
(以下略)

参考:使用pip install时出现“connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”错误。

看起来是与SSL认证相关的错误,但是即使仔细调查也不太清楚细节。。。

建议设置信任的主机并使用–trusted-host选项来运行。

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

然而,根据所安装的软件包不同,仍然可能会出现“证书验证失败”的错误。

在这种情况下,可以从Python Package Index下载文件并进行安装。

$ wget --no-check-certificate https://files.pythonhosted.org/packages/72/a4/d7a5738a3096f22a98bec1609e237b250ebff04e5ea2930305d485337263/pytest_runner-4.2-py2.py3-none-any.whl
$ pip install pytest_runner-4.2-py2.py3-none-any.whl
广告
将在 10 秒后关闭
bannerAds