Install Pyenv itself
Install relevant libraries
sudo apt-get install -y \
make build-essential libssl-dev zlib1g-dev git \
libbz2-dev libreadline-dev libsqlite3-dev wget curl \
llvm libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Install pyenv and do settings
curl https://pyenv.run | bash
echo -e '\n# Pyenv Configuration' >> ~/.bashrc
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
source ~/.bashrc
Check version
pyenv --version
List Up available Pythons
pyenv install --list
Update Python Version list
cd /home/your-home/.pyenv/plugins/python-build/../.. && git pull && cd -
Insutall Python with version
pyenv install 3.11.6
Create Virtual Environment
pyenv virtualenv ${VERSION} ${YOUR_ENV_NAME}
pyenv virtualenv 3.11.6 myenv
How to listup virtual envs
The environments are stored in this directory ~/.pyenv/versions/
If you want to listup it,
pyenv virtualenvs
Activate Virtual Environment
pyenv activate myenv
Deactivate Virtual Environment
pyenv deactivate