meta data for this page
Multiple python versions
pyenv
Installation
For fully automated installation:
curl https://pyenv.run | bash
Manual installation steps:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc # Restart shell to apply new PATH variable exec "$SHELL"
Install plugins
git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
Install Python build dependencies
sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev curl \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Install additional Pythons
# list of all available versions pyenv install -l pyenv install 3.11
Usage
$ python3 --version Python 3.9.2 $ pyenv global 3.11 $ python3 --version Python 3.11.4 $ pyenv global system $ python3 --version Python 3.9.2