Local Python Development

OS X Python Local Development Setup 2020

This assumes you are using ZShell and this is a brand new mac.

Install homebrew

Install pyenv
% brew install pyenv

Create a startup file for zshell and add a command to initialize pyenv
% echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc

Install Xcode command line tools
% xcode-select --install

Install recommended packages for pyenv
% brew install sqlite3 xz zlib

Use pyenv to install the latest version of python 3
% pyenv install 3.8.2

Set the latest python version as the default global version
% pyenv global 3.8.2

Install python virtual environment management tool
% brew install pyenv-virtualenv

Add these lines to the end of the ~/.zshrc file to initialize pyenv-virtualenv
if which pyenv-virtualenv-init > /dev/null; then
  eval "$(pyenv virtualenv-init -)"
fi

Comments