Install system-level dependencies
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl
Install pyenv
curl https://pyenv.run | bash
Decide which Python version we want to use
pyenv install --list | grep " 3\.10"
(change the 10
in the above grep
command to filter for the minor version you are looking for)
Install the Python version we want to use
pyenv install =PYTHON_VERSION=
Create the virtualenv
pyenv virtualenv =PYTHON_VERSION= =VIRTUALENV_NAME=
Activate the virtualenv
(this is automatically done if you use pyenv local
as below)
pyenv activate =VIRTUALENV_NAME=
(Optional) Make that virtualenv automatically activated when you are in this project
pyenv local =VIRTUALENV_NAME=