Installing multiple versions of python on linux using pyenv and create virtual environment.
Environment: Debian12
Default python version on debian12 is 3.11 but I need 3.10 to run my flask based back end.
1. Check default python version
python3 --version
2. Install version 3.10.13 (chose the version you need)
cd
sudo apt install curl git gcc make libssl-dev libbz2-dev
sudo apt install python3-setuptools
sudo apt install python3-pip
curl https://pyenv.run | bash
cd .pyenv/bin
./pyenv install --list
./pyenv install 3.10.13
cd ~/.pyenv/versions/3.10.13/bin/
./python3.10 --version
3. Create Virtual Environment
cd ~/.pyenv/versions/3.10.13/bin/
./python3.10 -m venv ~/.venv310
4. To activate virtual environment
cd
source .venv310/bin/activate
(.venv310):~$