Posted at

python3.7(windows10)でpipがSSL接続できないと言う場合はdllの衝突のせい


環境


  • Windows 10 Pro

  • conda 4.5.2

  • Python 3.7.3 (conda create -n hoge-env python=3.7)


問題

pip installできない。

C:\Users\me>activate hoge-env

(hoge-env) C:\Users\me>pip install "https://github.com/hoge/hoge.tgz"
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting https://github.com/hoge/hoge.tgz
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /hoge/hoge.tgz
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /hoge/hoge.tgz
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /hoge/hoge.tgz
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /hoge/hoge.tgz
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /hoge/hoge.tgz
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /hoge/hoge.tgz (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

import sslもできない。

(hoge-env) C:\Users\me>python

Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\me\Anaconda3\envs\hoge-env\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: 指定されたプロシージャが見つかりません。


解決法

https://github.com/pypa/virtualenv/issues/1139#issuecomment-481847818

C:\Windows\System32下のlibssl-1_1-x64.dlllibcrypto-1_1-x64.dllが本来のdllへの解決を邪魔しているらしいのでをどうにかする(リネームするとか)と解決した。

検索するといろいろ出てくるが、影響範囲が小さく何かあった場合の復旧も簡単なのでこれがベターではないかと思う。