User Tools

Site Tools


linux:ubuntu:install-multiple-python-versions

Installing another python version (2.7) with pyenv

Installing pyenv

curl https://pyenv.run | bash

Configuring pyenv

Add the following lines to your ~/.bashrc file:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
 
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
 
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
 
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Reload your shell configuration:

source ~/.bashrc

Installing Python 2.7

pyenv install 2.7.18

Using Python 2.7

To set Python 2.7 as the default version in the current directory:

pyenv local 2.7.18

To set Python 2.7 as the default version globally:

pyenv global 2.7.18

To revert to the system's Python 3.12:

pyenv global system

Verifying the version

python --version
linux/ubuntu/install-multiple-python-versions.txt · Last modified: 2025/04/22 15:12 by odefta