Skip to content

pyenv

Install

Run

curl https://pyenv.run | bash

Add to ~/.bashrc

vim ~/.bashrc
vim ~/.zshrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Requirements

Debian and Ubuntu


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

Commands

# List python versions available
pyenv install --list

# Install specific version
pyenv install -v 3.6.15
pyenv install -v 3.9
pyenv install -v 3.10
# pyenv install -v 2.7.18

# List versions installed
ls ~/.pyenv/versions/

# Switch forever to pyenv
pyenv global 3.6.15
pyenv global 3.9
pyenv global 3.10
# pyenv global -v 2.7.18

# Switch temporary python version
pyenv shell 3.9
# pyenv shell 2.7.18

# Switch directory python version
pyenv local 2.7.15

Sources