LoginSignup
2
2

More than 3 years have passed since last update.

公式サイト以外からpip installしてSSLError(SSL認証エラー)が出たときの解決法

Last updated at Posted at 2020-10-31

pip installでパッケージを入れる時SSL認証エラーが出ることが多々あるかと思います。

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='object-storage.tyo2.conoha.io', port=443): Max retries exceeded with url: /v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))

こんな感じ。

公式からダウンロードする場合はpipyの公式サイトのドメインを--trusted-host <ドメイン名>オプションで強制的に信用してしまえば解決できます。

具体的には・・・、

pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org <パッケージ名>

公式以外のサイトからパッケージをダウンロードする場合はこれだけじゃダメ

でも、公式以外のサイトからインストールする場合はこれだけではうまくいかないことがあります(だって、そのサイトのドメインはpipyのドメインとは関係ないから)。

例えばこう、

pip install https://object-storage.tyo2.conoha.io/v1/nc_2520839e1f9641b08211a5c85243124a/sudachi/SudachiDict_core-20190718.tar.gz

当たり前ですけど、このパッケージをインストールする場合は、パッケージを保存場所を表すURLのドメインを--trusted-hostオプションで信用してもらう必要がありますね。

上の例の場合なら、--trusted-host object-storage.tyo2.conoha.ioってぐあいです。

すごい簡単な話でしたが、だいぶ自分ははまったので同じ目にあった人は試してみてください。

それでは。

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2