I tried to update pip, and when I ran the command, I couldn't update because ssl wasn't working.
It turned out that due to the upgrade, I couldn't find the openssl library that was in it when I installed python. This time, the old version of openssl remained, so I could solve it by using install_name_tool to tell me the location of the shared library or re-pasting the symlink.
I tried to update pip, and when I ran the command, I got an error saying ssl wasn't working and couldn't update.
hoge-Macbook:~ hoge$ pip install -U pip
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/pip/
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/pip/
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/pip/
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/pip/
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/pip/
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
Requirement already up-to-date: pip in ./.pyenv/versions/3.6.3/lib/python3.6/site-packages (19.3.1)
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
When I tried import ssl from the python shell, I got an error that the library could not be found.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: dlopen(/Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so
Reason: image not found
It seems that the dynamic library /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so is messed up, so it depends on otool. I checked the library. As a result, I found that openssl requires version 1.0.0 of the library.
hoge-Macbook:Users hoge$ otool -L /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so
/Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so:
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
However, the directory (/ usr / local / opt / openssl / lib) that should contain the 1.0.0 library contained 1.1.
hoge-Macbook:Users hoge$ ls /usr/local/opt/openssl/lib
engines-1.1 libcrypto.a libssl.1.1.dylib libssl.dylib
libcrypto.1.1.dylib libcrypto.dylib libssl.a pkgconfig
ls -l /usr/local/opt/
lrwxr-xr-x 1 hoge admin 28 4 29 12:41 openssl -> ../Cellar/[email protected]/1.1.1f
That means I'm missing 1.0.0 and I'm getting an error, so I have to find openssl.
When I searched for it, it seems that openssl (ver1.0.0) still remained on the mac, so I decided to tell you the directory where 1.0.0 is located.
I used install_name_tool to rewrite the locations of the two dependent libraries libssl.1.0.0.dylib and libcrypto.1.0.0.dylib that came up when I ran otool.
install_name_tool -change /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2s/lib/libssl.1.0.0.dylib /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so
install_name_tool -change /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.1.0.0.dylib /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so
hoge-Macbook:procon hoge$ otool -L /Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so
/Users/hoge/.pyenv/versions/3.6.3/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so:
/usr/local/Cellar/openssl/1.0.2s/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
Even if you don't use install_name_tool, you can fix it by re-linking the symbolic link so that it points to 1.0.0.
ln -nfs /usr/local/Cellar/openssl/1.0.2s/ /usr/local/opt/openssl
You can import ssl by taking either 1 or 2 workaround, and pip I was able to update.
Recommended Posts