What to do if you get an OpenSSL error when installing Python 2 with pyenv

When I tried to install Python 2 with pyenv, I encountered an error related to OpenSSL and could not install it. I will write down the measures I took at that time.

Premise of this article

--You are using macOS --Installing OpenSSL with homebrew

error

When I installed Python2 series with pyenv, the following error occurred.

$ pyenv install 2.7.10
python-build: use openssl from homebrew
python-build: use readline from homebrew

...abridgement...

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.15.5 using python-build 1.2.18-19-gcf81e5a0)

From Missing the OpenSSL lib?, You can see that there is a problem with OpenSSL.

Solution

The reason why this error occurred in my environment was that the version of OpenSSL installed by homebrew is not 1.0 series. OpenSSL 1.0 series is required to install Python 2 series.

Check the version of OpenSSL

Let's check the version of OpenSSL installed by brew.

$ brew info openssl
[email protected]: stable 1.1.1g (bottled) [keg-only]

Uninstall OpenSSL

Temporarily unintall OpenSSL 1.1.

$ brew uninstall --ignore-dependencies openssl

The reason for adding --ignore-dependencies is to ignore the dependencies and force the uninstall. (If it depends on other software, it cannot be uninstalled without this option)

Installation of Python 2 series

Next, install Python 2 series with pyenv. You don't need to install OpenSSL 1.0 series by yourself because pyenv will install OpenSSL 1.0 series without permission.

$ pyenv install 2.7.10
Installing openssl-1.0.2k...
Installed openssl-1.0.2k to /Users/hogesuke/.anyenv/envs/pyenv/versions/2.7.10

Reinstall OpenSSL 1.1

After successfully installing Python 2, reinstall the uninstalled OpenSSL 1.1 with homebrew.

$ brew install openssl

reference

https://fumimaker.hatenablog.com/entry/2020/02/18/203434

Recommended Posts

What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do if you get an error when installing python with pyenv
What to do if you get an error when installing Dlib (Ubuntu)
What to do if you get an Undefined error when trying to use pip with pyenv
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you get an Import Error when importing matplotlib with Jupyter
What to do if you get an error when trying to load mnist
What to do if you run python in IntelliJ and end with an error
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if you couldn't send an email to Yahoo with Python.
What to do if pyenv install does not proceed with an error
What to do if an error occurs when importing numpy with VScode
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
Workaround if you get an error when trying to install PySide with pip
What to do when an error occurs with import _ssl
What to do if you get an error like'Qstring' has already been set to version 1 using mne python
What to do if you get a "Wrong Python Platform" warning when using Python with the NetBeans IDE
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
What to do if you get an "unknown service" error from your gRPC server
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
What to do if an error occurs when loading a python project created with poetry into VS Code
What to do if you can't install pyaudio with pip #Python
What to do if you get a minus zero in Python
[Beanstalk] What to do when an error occurs with import uuid
What to do if you get a UnicodeDecodeError with pip install
What to do when you get an error saying "Name resolution temporarily failed" on linux
What to do if you get Swagger-codegen in python and Import Error: No module named
What to do if you get lost in file reference with FileNotFoundError
[Python] What to do when an error related to SSL authentication is returned
What to do if you get a TypeError with numpy min, max
What to do if you get Could not fetch URL 443 with pip
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do if you get an error saying c compiler cannot create executables in configure
What to do if you get a must override `get_config` error when trying to model.save in Keras
What to do if you get angry if you don't have libxml / xmlversion.h when installing lxml on CentOS
What to do if pip --user returns an error in a virtual environment created with pyenv
What to do if you get an error when vagrant up when you enable public_network or private_network on Vagrant + Arch Linux → Install netctl
When you get an error in python scraping (requests)
What to do when you can't bind CaboCha to Python
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What to do if you get a "No versions found" error in pipenv
What to do if you get angry with swapon failed: Operation not permitted
[python] What to do when an error occurs in send_keys of headless chrome
What to do if you get "Python not configured." Using PyDev in Eclipse
[Python] What to check when you get a Unicode Decode Error in Django
If you get a long error when tabbing an interactive shell with Anaconda
What to do if you get "The session could not be opened" when installing CentOS on VirtualBox
What to do if you get a Permission denied (public key) error when trying to pull on Github
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
What to do if you get the error Target WSGI script'/var/www/xxx/xxx.wsgi' cannot be loaded as python module
EC2 / Amazon Linux2: What to do if you get an "unable to execute'gcc': No such file or directory" error with pip install
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
[AWS] What to do when you want to pip with Lambda
What to do if you get `No kernel for language python found` in Hydrogen
What to do if the print command itself causes an error in Maya python
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if you get "coverage unknown" in Coveralls
What to do if you can't sort files with subscripts
What to do with PYTHON release?