Install Multiple Python Versions for Specific Project
-
Home project: https://github.com/pyenv/pyenv
-
Reference to: https://www.tecmint.com/pyenv-install-and-manage-multiple-python-versions-in-linux/
# On Debian/Ubuntu/Linux Mint ------------
sudo apt install curl git-core gcc make zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libssl-dev
# On CentOS/RHEL ------------
sudo yum -y install epel-release
sudo yum -y install git gcc zlib-devel bzip2-devel readline-devel sqlite-devel openssl-devel
# On Fedora 22+ ------------
sudo yum -y install git gcc zlib-devel bzip2-devel readline-devel sqlite-devel openssl-devel
git clone https://github.com/pyenv/pyenv.git $HOME/.pyenv
vim $HOME/.bashrc
## pyenv configs
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
source $HOME/.bashrc
# or:
exec "$SHELL"
# View all available versions with this command.
pyenv install -l
# You can now install multiple Python version via pyenv, for example.
pyenv install 3.6.4
pyenv install 3.6.5
# List all Python versions available to pyenv
pyenv versions
# Check the global Python version
pyenv global
# Set the global python version using the pyenv command
pyenv global 3.6.5
pyenv global
# Set the local Python version on per-project basis
# For instance, if you have a project located in $HOME/python_projects/test,
# you can set the Python version of it using following command.
cd python_projects/test
pyenv local 3.6.5
pyenv version #view local python version for a specific project, or:
pyenv versions
Pyenv manages virtual environments via the pyenv-virtualenv plugin which automates management of virtualenvs and conda environments for Python on Linux and other UNIX-like systems.
git clone https://github.com/yyuu/pyenv-virtualenv.git $HOME/.pyenv/plugins/pyenv-virtualenv
source $HOME/.bashrc
called venv_project1 under a project called project1 as follows
cd python_projects
mkdir project1
cd project1
pyenv virtualenv 3.6.5 venv_project1
For installing Python 3.12.0 on Fedora 38 ARM, I also had to install tkinter. The following worked for me:
And then I was able to install Python 3.12.0 without issue: