Skip to content

Instantly share code, notes, and snippets.

@drobilc
Last active August 30, 2022 15:40
Show Gist options
  • Save drobilc/6bc2dbbb6f1d3324e278b9fc124e9d75 to your computer and use it in GitHub Desktop.
Save drobilc/6bc2dbbb6f1d3324e278b9fc124e9d75 to your computer and use it in GitHub Desktop.
Install Python 3.9.13 on Ubuntu 16.04 (Okeanos virtual machine)

Python 3.9.13 installation instructions

Install Python 3.9.13 on Okeanos virtual machine running Ubuntu 16.04.

The tutorial assumes that the current user is user.

Install make

sudo apt-get install build-essential

Install OpenSSL library

# Download the latest version of the OpenSSL library
# See https://www.openssl.org/source/ for newer versions.
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz

# Extract the downloaded file.
tar zxvf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q/

# Configure and build the OpenSSL library.
./config --prefix=/home/user/openssl --openssldir=/home/user/openssl no-ssl2
make
make install

cd ~

Edit the OpenSSL configuration

Edit the ~/.profile file (using nano ~/.profile or vim ~/.profile). Add the following lines.

export PATH=$HOME/openssl/bin:$PATH
export LD_LIBRARY_PATH=$HOME/openssl/lib
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L /home/user/openssl/lib -Wl,-rpath,/home/user/openssl/lib"

Reload the file using . ~/.profile

Install pyenv

curl https://pyenv.run | bash

Add the following lines to both the ~/.profile and the ~/.bashrc files.

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Then load the scripts exec $SHELL.

Install Python 3.9.13

# Install Python 3.9.13
CONFIGURE_OPTS="--with-openssl=/home/user/openssl --with-openssl-rpath=auto" pyenv install 3.9.13

# Set Python 3.9.13 as your global Python version
pyenv global 3.9.13

The installed Python 3.9.13 can now be executed using python3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment