Based on:
- https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
- https://medium.com/@miqui.ferrer/the-ultimate-guide-to-managing-python-virtual-environments-in-macos-c8cb49bf0a3c
xcode
xcode-select --install
Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
To install required components
brew install openssl readline sqlite3 xz zlib tcl-tk pyenv pyenv-virtualenv
Configure zshrc
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
source ~/.zshrc
Check that everything works with pyenv --help
Install python versions with pyenv install x.y.z
. Using pyenv allows you to install multiple version from different vendors. Use pyenv install -l
to list all available versions (including regular, anaconda and stackless versions)
Create a virtual environment with pyenv virtualenv 3.9.18 new-venv
Activate environment with pyenv activate new-venv
and deactivate with pyenv deactivate
- About Virtualenv
- A good collection of .gitignore files, including a Python one ;)