LoginSignup
3
3

More than 1 year has passed since last update.

pip install のエラーの解決策 【Python】【Mac】

Last updated at Posted at 2020-05-20

pythonエンジニアで初心者の自分が困ってて解決したことをシェアします。

pip install のエラー

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

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/pip/

などのエラーが出た時の対処法

根本的な原因が全く分からないので、とりあえずエラー文章やsslとは、など初めて見る単語を調べてました。解決策自体はいろいろあるみたいです。

-環境-
macOS 10.14.6
python 3.6.6
venv(仮想環境)

原因

おそらくpip/pythonが古いopenssl(1.0.2s)を参照しているのではありませんか? 情報を見る限り、質問者の方のopensslは最新版になっているので参照エラーが起きているように思います

下記でsslが使えるかチェックします。

py
import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/[username]/.pyenv/versions/3.7.0/lib/python3.7/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: dlopen(/Users/[username]/.pyenv/versions/3.7.0/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/LO/.pyenv/versions/3.7.0/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so
  Reason: image not found

エラーが出たので

結論

sh
$ brew switch openssl 1.0.2s

pip install でSSL関連のエラーが出たらこれを読め!!!
これだけです。
sslが切り替わってなかったんですね。
解決してみると原因はシンプルで分かりやすかったです。


自分なりに解釈してるところが、あるかもしれませんが助けになれば幸いです。

3
3
0

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
3
3