published: 24th of November 2020
Pyenv is a similar tool to rbenv, where you can easily install and use mulitple versions of python. This allows you to test across multiple versions of python as well as pin an app to a specific release.
Install the dependencies required to use pyenv.
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y zlib zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel
Use the installed script to install pyenv.
curl https://pyenv.run | bash
Update your shell environment, I am using zsh.
# ~/.zshrc
# PYENV
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# PYENV Auto-completions. This should be towards the end of the file.
eval "$(pyenv init -)"
Restart your shell environment.
exec "$SHELL"
Verify the version of pyenv installed.
pyenv --version
# output
pyenv 1.2.21
Install a version of python.
# Python 3
pyenv install 3.8.6
# Python 2
pyenv install 2.7.16
Install a version of python.
# Python 3
pyenv install 3.8.6
# Python 2
pyenv install 2.7.16
Use a version of python.
# Application specific python version(s).
pyenv local 3.8.6 2.7.16
# Systemwide python version(s)
pyenv global 3.8.1 2.7.18
Welcome to the end. If you followed along you will have pyenv installed and configured for use on Centos 8.
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-installer
https://medium.com/@aokany/pyenv-installation-and-python-venv-usage-on-centos-8-68a144b88203