当前位置: 首页 > 知识库问答 >
问题:

Windows上的Pip SSL错误

滕夜洛
2023-03-14

我使用Python3。Windows 7上的x 64位,在无法完全控制入站/出站流量处理的环境中。到本周为止,我已经能够使用——可信主机pypi。pythonorg标记pip,一切正常。本周,即使使用了--trusted host标志,我也开始出现以下错误。

Could not fetch URL https://pypi.python.org/simple/pytubes/: There was a probl
em confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed (_ssl.c:720) - skipping

鉴于本周的pypi更改,我尝试将--可信主机标志更改为https://files.pythonhosted.org/packages/,但这似乎没有帮助。

我还尝试下载和安装certifi、wincerstore和win32 certifi的轮子,以及针对此类问题的其他stackoverflow建议,如digistore。pem证书和pip。没有任何成功的ini文件。

pip安装失败,原因是“连接错误:[SSL:CERTIFICATE\u VERIFY\u FAILED]CERTIFICATE VERIFY FAILED(\u SSL.c:598)”

最后,我尝试将pip从PIP9.0升级到PIP10。3按照此处的说明进行操作:https://pip.pypa.io/en/stable/installing/

对于curl下载,我必须传入-k,并运行python get-pip。py失败,并出现与pip类似的ssl错误:

 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:749)'),)': /simple/pip/
  Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),)) - skipping
  Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),)) - skipping

感谢对下一步的任何建议,因为. pem文件、Python CA包和--可信主机标志没有做到这一点

编辑:

从下面的答案中,在pip中使用-vvv标志的新输出。

 > pip install pytubes -vvv
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Collecting pytubes
  1 location(s) to search for versions of pytubes:
  * https://pypi.python.org/simple/pytubes/
  Getting page https://pypi.python.org/simple/pytubes/
  Looking up "https://pypi.python.org/simple/pytubes/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  Could not fetch URL https://pypi.python.org/simple/pytubes/: There was a probl
em confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed (_ssl.c:749) - skipping
  Could not find a version that satisfies the requirement pytubes (from versions
: )
Cleaning up...
No matching distribution found for pytubes
Exception information:
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\basecommand.py", line 215
, in main
    status = self.run(options, args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", lin
e 335, in run
    wb.build(autobuilding=True)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in b
uild
    self.requirement_set.prepare_files(self.finder)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380
, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 554
, in _prepare_file
    require_hashes
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_install.py", line
 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\index.py", line 514, in f
ind_requirement
    'No matching distribution found for %s' % req
pip.exceptions.DistributionNotFound: No matching distribution found for pytubes
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
There was an error checking the latest version of pip
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\connectionpool.py", line 595, in urlopen
    chunked=chunked)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\connectionpool.py", line 352, in _make_request
    self._validate_conn(conn)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\connectionpool.py", line 831, in _validate_conn
    conn.connect()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\connection.py", line 289, in connect
    ssl_version=resolved_ssl_version)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\util\ssl_.py", line 308, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\ProgramData\Anaconda3\lib\ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "C:\ProgramData\Anaconda3\lib\ssl.py", line 808, in __init__
    self.do_handshake()
  File "C:\ProgramData\Anaconda3\lib\ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "C:\ProgramData\Anaconda3\lib\ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c
:749)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\adapters
.py", line 423, in send
    timeout=timeout
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\packages
\urllib3\connectionpool.py", line 621, in urlopen
    raise SSLError(e)
pip._vendor.requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VER
IFY_FAILED] certificate verify failed (_ssl.c:749)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\outdated.py", line
126, in pip_version_check
    headers={"Accept": "application/json"},
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions
.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\download.py", line 386, i
n request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions
.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions
.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\cachecontrol\adap
ter.py", line 47, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\requests\adapters
.py", line 497, in send
    raise SSLError(e, request=request)
pip._vendor.requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certi
ficate verify failed (_ssl.c:749)

共有3个答案

袁桐
2023-03-14

以下解决方案对我有效:

  1. 转到运行。键入%appdata%
[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org
               raw.githubusercontent.com
               github.com
饶德元
2023-03-14

您可能是一个讨厌的代理服务器的幕后黑手,该服务器通过中间人攻击来进行深度数据包检查。您需要从代理管理员处获取CA证书文件,以便告诉Python一切正常。您还可以从web浏览器或任何其他配置为使用代理的内容中提取此内容。

获得证书后,您可以将其添加到cacert。certifi软件包的pem文件,或使用--cert选项或全局选项直接告知pip。pip中的证书。conf文件。

饶滨海
2023-03-14

最终对我有用的是添加所有属于新pypi路由的域。

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

也可以设置在pip.ini文件中。

 类似资料:
  • 我正在尝试在Windows x64(8.1和Server 2012 R2)上安装Apache Hadoop 2.7.1,但目标失败: 在过去的日子里,我想我遵循了所有教程的步骤,比如HadoopOnWindows,或者这个。我做了所有的先决条件,但是当我谷歌时,我的问题的相关条件如下: 将路径设置为MSBuild。exe类似于:C:\Windows\Microsoft。NET\Framework6

  • 在多次尝试并更改bat文件后,我终于成功地在Windows 7中运行了Kafka和Zookeeper。这是一台运行Java 7的32位计算机。但不幸的是,我无法创建主题。我尝试在这里使用教程:http://janschulte.wordpress.com/2013/10/13/apache-kafka-0-8-on-windows/ 我执行了命令: C:\Cambria\kafka_2.8.0-0

  • 我刚刚安装完RubyonRails包(Rails4.1.8)。在为其创建一个新目录后,如,当它到达时,通常会收到此错误消息 “Gem::RemoteFetcher::FetchError:SSL\u connect返回=1 errno=0 state=SSLv3读取服务器证书B:证书变量失败https://rubygems.org/gems/rake-10.4.0gem.安装rake时出错

  • docker Run-P 8080:8080-P 50000:50000-V//D/Jenkins://var/Jenkins_Home Jenkins 我还尝试了以下方法 docker run-P 8080:8080-P 50000:50000-V Jenkins_Home://d/Jenkins_Workspace jenkins 致命:命令执行失败java.io.ioException:er

  • C:\Project\Angular2Demo\Angular2Demo npm错误!网络getaddrinfo ENOTFOUND注册表。npmjs。组织注册处。npmjs。组织:443 NPM ERR!网络这很可能不是npm本身的问题npm ERR!网络和网络连接有关。npm ERR!网络在大多数情况下,你是背后的代理或有坏的网络设置GS. npm ERR!网络npm ERR!网络如果您是背后