pipでSSLエラー

先日に引き続きpipでエラー。今回はOpenSSLをインストールすることにより解消した。

現象

pipを実行するとSSLのWARNINGが出力され、インストール自体はERRORとなる

C:\Users\xxxxx>py -m pip install python-pptx –user
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
Could not fetch URL https://pypi.org/simple/python-pptx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /simple/python-pptx/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) – skipping
ERROR: Could not find a version that satisfies the requirement python-pptx (from versions: none)
ERROR: No matching distribution found for python-pptx

原因

不明。前回pipを実行してからの変更点として心当たりがあるのは

  • Windows Update(20H2)の適用
  • Anacondaの再インストール

どちらも原因として考えられそうだがよく分からない。Windows Updateを戻すのは現実的ではない(現象が回復したとして、ずっとWindowsUpdateを適用しないわけにはいかない)し、Anacondaを再インストールしたのは文字化けを解消するため。上記環境は変えないまま現象を改善する必要がある。

試したこと

信頼済みサイト設定

下記オプションを指定して解消した事例があったので試してみた。

  • –trusted-host pypi.python.org
  • –trusted-host files.pythonhosted.org
  • –trusted-host pypi.org

C:\Users\xxxxx>pip install –trusted-host pypi.org –trusted-host pypi.python.org –trusted-host files.pythonhosted.org python-pptx
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
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.”)’: /simple/python-pptx/
Could not fetch URL https://pypi.org/simple/python-pptx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /simple/python-pptx/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) – skipping
ERROR: Could not find a version that satisfies the requirement python-pptx (from versions: none)
ERROR: No matching distribution found for python-pptx
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

駄目。

ファイアーウォール無効化

とりあえず原因の切り分けのため一時的にWindowsファイアーウォールを無効化してみた。

が、駄目。

コマンドプロンプトを管理者権限で起動

全然駄目。

解消

OpenSSLを手動インストール後にリトライしてみた。

C:\Users\xxxxx>py -m pip install python-pptx –user
Collecting python-pptx
Downloading python-pptx-0.6.18.tar.gz (8.9 MB)
|████████████████████████████████| 8.9 MB 3.3 MB/s
Requirement already satisfied: lxml>=3.1.0 in c:\users\xxxxx\anaconda3\lib\site-packages (from python-pptx) (4.6.1)
Requirement already satisfied: Pillow>=3.3.2 in c:\users\xxxxx\anaconda3\lib\site-packages (from python-pptx) (8.0.1)
Requirement already satisfied: XlsxWriter>=0.5.7 in c:\users\xxxxx\anaconda3\lib\site-packages (from python-pptx) (1.3.7)
Building wheels for collected packages: python-pptx
Building wheel for python-pptx (setup.py) … done
Created wheel for python-pptx: filename=python_pptx-0.6.18-py3-none-any.whl size=275708 sha256=1ad5cbd077c54f4d7f8c326ce085ddb1a041744e2dc4690e40ead1ce6012f424
Stored in directory: c:\users\xxxxx\appdata\local\pip\cache\wheels\11\2b\97\d82ca57932fa62d52c723024419c5ec3b7c0f7ecf0a0f06332
Successfully built python-pptx
Installing collected packages: python-pptx
Successfully installed python-pptx-0.6.18

WARNINGもなく無事完了。しかしなんで急に失敗するようになったんだろうか。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA