Install Python 3.9.13 on Okeanos virtual machine running Ubuntu 16.04.
The tutorial assumes that the current user is user
.
sudo apt-get install build-essential
# 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 ~/.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
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
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
.