Skip to content

Instantly share code, notes, and snippets.

@ariesmcrae
Last active December 20, 2024 05:23
Show Gist options
  • Save ariesmcrae/49dd7b6ec8b1c0663ad35bb849f8880a to your computer and use it in GitHub Desktop.
Save ariesmcrae/49dd7b6ec8b1c0663ad35bb849f8880a to your computer and use it in GitHub Desktop.
Install python on macOS using pyenv

Pyenv will allow you to switch to different versions of python locally (much like nvm for node.js or jenv for java)

Install pyenv

brew install pyenv

Add this to your ~/.zshrc

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

List versions of python you have locally (what were installed via pyenv)

pyenv versions

List versions of python from the internet

pyenv install --list

Install a specific version of python

pyenv install 3.11.0

To set a default Python version globally:

pyenv global 3.11.0

##To specify a Python version only for a particular project directory :

cd /path/to/your/project
pyenv local 3.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment