Install Latest Python (3.7) on Ubuntu via Pyenv

August 29, 2018

Install pyenv.

curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | 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

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.