Install Latest Python (3.7) on Ubuntu via Pyenv

February 23, 2021
Install different/multiple version of Python

Install pyenv.

curl -L | bash

NOTE: curl | bash is a risky command, make sure to execute them from trusted source only.

Add the following to ~/.bash_profile, ~/.profile or ~/.bashrc.

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

NOTE: I am using Lubuntu 16.04, and only ~/.bashrc works.

Start a new terminal or run source ~/.bashrc.

Check for update.

pyenv update

Install latest python.

pyenv install 3.7.0

NOTE: Check latest python version

NOTE: Refer to Ubuntu 18.04 Pyenv Build Python 3.7 Common Error.

Check for available versions.

pyenv versions

Create a pyenv virtualenv named test.

pyenv virtualenv 3.7.0 test

Activate virtualenv

pyenv activate test

Deactivate virtualenv

pyenv deactivate

List all virtualenv

pyenv virtualenvs

Delete/Uninstall virtualenv

pyenv uninstall env

NOTE: Refer to Install Python (Make from Source) or apt-get as well.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.