Dev Environment
Pyenv

Pyenv

Pyenv (opens in a new tab)

pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

Pyenv

Install Pyenv (MacOS)

brew update
brew install pyenv
 
# Dependencies
brew install openssl@1.1 openssl readline sqlite3 xz zlib

Install Pyenv (Debian/Ubuntu)

curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
 
# Dependencies
sudo apt-get install -y 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

Setup shell environment

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
 
# Restart shell to apply changes
exec "$SHELL"

Install additional Python versions

# e.g. Download and install Python 3.10.4
pyenv install 3.10.4
 
# Automatically select whenever you are in the current directory (or subdirectories)
pyenv local 3.10.4
 
# Select globally for your user account
pyenv global 3.10.4

Virtualenv

Install virtualenvwrapper (MacOS)

PIP_REQUIRE_VIRTUALENV=false pip install virtualenvwrapper
brew install pyenv-virtualenvwrapper

Install virtualenvwrapper (Debian/Ubuntu)

PIP_REQUIRE_VIRTUALENV=false pip install virtualenvwrapper
sudo apt install pyenv-virtualenvwrapper

Add to shell config if they're not there

# virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
pyenv virtualenvwrapper