2

Compiling Python 3.7 and up on Ubuntu 14.04 doesn't work out of the box. This is because Ubuntu 14.04 is baselined on OpenSSL 1.0.1 and Python 3.7 requires OpenSSL 1.0.2 and up.

What is the best solution that doesn't involve 3rd party PPAs?

1 Answer 1

8

I didn't see a single definitive solution so I decided to write one on compiling from source without impacting the rest of the system.

You need two steps, one is building your own version of OpenSSL and the second is instructing pyenvto use it.

To install OpenSSL, run the following commands.

mkdir openssl 
cd openssl 
wget https://www.openssl.org/source/openssl-1.0.2u.tar.gz 
tar -xzvf openssl-1.0.2u.tar.gz 
cd openssl-1.0.2u 
./config --prefix=$HOME/openssl --openssldir=$HOME/openssl shared zlib 
make 
make install

This installs the latest version on OpenSSL 1.0.2 (no more patches will be released) to your home directory. Now to install Python 3.7 using pyenv.

After you configure pyenv, run the following command

PATH="$HOME/openssl:$PATH" CPPFLAGS="-I$HOME/openssl/include" CFLAGS="-I$HOME/openssl/include/" LDFLAGS="-L$HOME/openssl/lib -Wl,-rpath,$HOME/openssl/lib" LD_LIBRARY_PATH=$HOME/openssl/lib:$LD_LIBRARY_PATH LD_RUN_PATH="$HOME/openssl/lib" CONFIGURE_OPTS="--with-openssl=$HOME/openssl" PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5

You may add -O2 if you want faster run times.

Sign up to request clarification or add additional context in comments.

2 Comments

Should there be two make calls in there? I received a linker error when running the above snippet, will see if I can figure out what's going on.
Obviously not, thanks for fixing the typo! What error are you running into?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.