sudo apt update
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-devcurl https://pyenv.run | bashIf you see
WARNING: Can not proceed... Kindly remove the '/home/USER/.pyenv' directory first— pyenv is already installed, skip this step.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrcpyenv --version
# pyenv 2.x.xpyenv install 3.12.0pyenv global 3.12.0cd ~/Desktop/NeSy/backend
pyenv local 3.12.0The local version creates a
.python-versionfile in the folder and is automatically activated whenever you enter that directory.
ls /usr/bin/python*pyenv versionsExample output:
system
* 3.12.0
3.11.5
The * indicates the currently active version.
python --version
which python# (while venv is activated)
python --version
which python| Action | Command |
|---|---|
| List all pyenv versions | pyenv versions |
| Install a Python version | pyenv install 3.12.0 |
| Set global version | pyenv global 3.12.0 |
| Set local version | pyenv local 3.12.0 |
| Check current version | python --version |
| Check Python path | which python |
| Create venv | python -m venv .venv |
| Activate venv | source .venv/bin/activate |
| Deactivate venv | deactivate |
| Verify SSL | python -c "import ssl; print(ssl.OPENSSL_VERSION)" |