Skip to content

Instantly share code, notes, and snippets.

@mwinters0
Last active December 21, 2021 19:37
Show Gist options
  • Save mwinters0/219e1e8e54caf83fc1216b55a530d3cb to your computer and use it in GitHub Desktop.
Save mwinters0/219e1e8e54caf83fc1216b55a530d3cb to your computer and use it in GitHub Desktop.
Mac python setup

Mac python

Assumes zsh and homebrew

Pyenv (python versions)

Installing pyenv

brew install python3 pyenv
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Installing other needed tools

xcode-select --install
brew install openssl readline sqlite3 xz zlib

Installing (building) a python version

pyenv versions
pyenv install --list
pyenv install 3.9.9

Each project

pyenv local 3.9.9 # creates ./python-version which the pyenv python shim will find
python --version

Pipenv

Installing pipenv

brew install pipenv

# We want to tell pipenv to use the pyenv python shim.  But the only input it
# accepts is a version number, which it will use to find our pyenv python.
echo 'alias pipenv="$(which pipenv) --python $(pyenv version-name)"' >> ~/.zshrc

Each project

  • init venv: pipenv install
  • rm venv / reset: pipenv --rm
  • add package: pipenv install <package>
  • check outdated: pipenv update --outdated
  • update single package: pipenv update <package>
  • update all packages: pipenv update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment