概要
bashからfishに変えてから,以前まではできていた,pyenvでpythonのインストールとpipでパッケージのインストールができなくなったのでその対処法を紹介します.
事象
例えば下記のようなエラーが発生しています.
pip install selenium 30.8s
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting selenium
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/selenium/
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/selenium/
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/selenium/
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/selenium/
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/selenium/
Could not fetch URL https://pypi.org/simple/selenium/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/selenium/ (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 selenium (from versions: none)
ERROR: No matching distribution found for selenium
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
- opensslそもそもある?
$ which openssl
/usr/local/opt/openssl/bin/openssl
ありますね...
解決方法
opensslが失敗しているので,読み込めてない可能性があります.
- config.fishに以下を追記
~/.config/fish/config.fish
set -x PATH /bin $PATH # なければ追加
set -x PATH /usr/local/bin $PATH # なければ追加
set -x PATH /usr/local/opt/openssl/bin $PATH # 一番重要
- プロファイルの適用
$ source ~/.config/fish/config.fish
- pythonのインストール
無事pythonをインストールするっことができました
pyenv install 3.6.2 786ms
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.2.tar.xz...
-> https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
Installing Python-3.6.2...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.6.2 to /Users/taro/.anyenv/envs/pyenv/versions/3.6.2