Ich verwende Python 3.x unter Windows 7 64 Bit in einer Umgebung ohne vollständige Kontrolle der Verarbeitung von eingehendem/ausgehendem Verkehr. Bis zu dieser Woche konnte ich das --trusted-Host pypi.python.org
-Flag mit pip verwenden und alles hat funktioniert. Diese Woche habe ich bereits mit dem Flag --trusted-Host
die folgende Fehlermeldung erhalten.
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
Ich habe versucht, das Flag --trusted-Host
in https://files.pythonhosted.org/packages/
zu ändern, da sich diese Änderung in dieser Woche geändert hat, aber das schien nicht zu helfen.
Ich habe auch versucht, die Räder von certifi, wincerstore und win32 certifi sowie andere Vorschläge für den Stackoverflow für diese Art von Problem herunterzuladen und zu installieren, beispielsweise die Dateien digistore .pem cert und pip.ini.
Schließlich habe ich versucht, Pip auf Pip 10 von Pip 9.0.3 zu aktualisieren, indem ich den Anweisungen hier folgte: https://pip.pypa.io/de/stable/installing/
Für den curl-Download musste ich -k
übergeben, und das Ausführen von python get-pip.py
schlägt mit einem ähnlichen ssl-Fehler fehl:
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
Schätzen Sie alle Vorschläge für die nächsten Schritte, da die PEM-Datei, die Python-CA-Pakete und das Flag --trusted-Host
den Trick nicht ausgeführt haben
Bearbeiten:
Neue Ausgabe mit dem Flag -vvv in pip aus einer Antwort unten.
> 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)
Was am Ende für mich funktioniert hat, ist das Hinzufügen aller Domänen, die Teil des neuen Pypi-Routings sind.
pip install --trusted-Host pypi.org --trusted-Host pypi.python.org --trusted-Host files.pythonhosted.org <package>
Die kann auch in einer pip.ini-Datei eingerichtet werden.
Sie befinden sich wahrscheinlich hinter einem unangenehmen Proxy-Server, der einen Man-in-the-Middle-Angriff ausführt, um eine tiefe Paketprüfung durchzuführen. Sie müssen die CA-Zertifikatsdatei von Ihrem Proxy-Administrator erhalten, um Python mitzuteilen, dass alles in Ordnung ist. Sie können dies auch aus Ihrem Webbrowser oder einem anderen Element extrahieren, das für die Arbeit mit dem Proxy konfiguriert ist.
Wenn Sie das Zertifikat erhalten haben, können Sie es entweder der Datei cacert.pem des certifi-Pakets hinzufügen oder pip direkt mit der Option --cert
oder global.cert
in der Datei pip.conf informieren.
Ich habe seit ein paar Tagen ähnliche Probleme mit Pip. Anscheinend haben sie das Sicherheitszertifikat für pypi.python.org aktualisiert, da es ab dem 28. März 2018 gültig ist und derzeit nur TLS 1.2 unterstützt.
Informationen zum aktuell verwendeten Zertifikat finden Sie unter hier .
BEARBEITEN:
Mögliches Duplikat von pip schlägt immer fehl ssl verifizierung
EDIT2:
@Alexander: Welche Version von Python 3.X verwendest du genau? Stellen Sie sicher, dass Sie mindestens Python 3.1 haben, tun Sie einfach python --version
.
EDIT3:
Ich meinte: 3.6.1.
Ich hatte das gleiche Problem und löste es während der Installation von Tensorflow. Hier ist die Lösung in Schritten:
Greifen Sie auf die für SSL relevante Datei zu. Suchen Sie den Ordner im Installationsverzeichnis, in dem sich sessions.py
befindet. (Ich denke es ist im Ordner ~~~ ₩ pip ₩ vender ₩ Anfragen)
Öffnen Sie sessions.py
und ändern Sie self.verify = True
in self.verify = False
.
Installieren Sie den vertrauenswürdigen Host-Code wie folgt
pip install --trusted-Host pypi.org --trusted-Host files.pythonhosted.org <package name>