pip install échoue avec "connection error : [SSL : CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)&quot ;

Je suis très nouveau à Python et j'essaie de > pip install linkchecker sur Windows 7. Quelques notes :

  • pip install échoue quel que soit le paquet. Par exemple, > pip install scrapy aboutit également à l'erreur SSL.
  • L'installation classique de Python 3.4.1 inclut pip 1.5.6. La première chose que j'ai essayé de faire était d'installer linkchecker. Python 2.7 était déjà installé, il était fourni avec ArcGIS. python et pip n'étaient pas disponibles à partir de la ligne de commande jusqu'à ce que j'installe 3.4.1.
  • > pip search linkchecker fonctionne. C'est peut-être parce que pip search ne vérifie pas le certificat SSL du site.
  • Je suis dans un réseau d'entreprise mais nous ne passons pas par un proxy pour accéder à Internet.
  • Chaque ordinateur de l'entreprise (y compris le mien) possède une autorité de certification racine de confiance qui est utilisée pour diverses raisons, notamment pour permettre la surveillance du trafic TLS vers https://google.com. Je ne sais pas si cela a un rapport avec le problème.

Voici le contenu de mon pip.log après avoir exécuté pip install linkchecker :

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

Vous pouvez spécifier un certificat avec ce paramètre :

pip --cert /etc/ssl/certs/FOO_Root_CA.pem install linkchecker

Voir : [Docs &#187 ; Guide de référence &#187 ; pip][1]

Si la spécification du certificat racine de votre entreprise ne fonctionne pas, peut-être que le certificat cURL fonctionnera : http://curl.haxx.se/ca/cacert.pem

Vous devez utiliser un fichier PEM et non un fichier CRT. Si vous avez un fichier CRT, vous devrez convertir le fichier en PEM Il y a des rapports dans les commentaires indiquant que cela fonctionne maintenant avec un fichier CRT mais je n'ai pas vérifié.

Vérifiez également : [Vérification des certificats SSL][3].

[1] : https://pip.readthedocs.io/en/latest/reference/pip/#cmdoption--cert

[3] : http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification

Commentaires (11)

Vous pouvez essayer de contourner l'erreur SSL en utilisant http au lieu de https. Bien sûr, ce n'est pas optimal en termes de sécurité, mais si vous êtes pressé, cela devrait faire l'affaire :

pip install --index-url=http://pypi.python.org/simple/ linkchecker
Commentaires (9)

J'ai résolu ce problème en supprimant mon pip et en installant l'ancienne version de pip : https://pypi.python.org/pypi/pip/1.2.1

Commentaires (5)