Quantcast
Channel: 初心者タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 21089

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

$
0
0

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
importssl
Traceback(mostrecentcalllast):File"<stdin>",line1,in<module>File"/Users/[username]/.pyenv/versions/3.7.0/lib/python3.7/ssl.py",line98,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):Librarynotloaded:/usr/local/opt/openssl/lib/libssl.1.0.0.dylibReferencedfrom:/Users/LO/.pyenv/versions/3.7.0/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.soReason:imagenotfound

エラーが出たので

結論

sh
$ brew switch openssl 1.0.2s

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


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


Viewing all articles
Browse latest Browse all 21089

Trending Articles