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
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.