curl https://pyenv.run | bash
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
pyenv install 2.7.18
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
python --version