The following should work on a fresh Mac. It should also work if you already have some kind of Python installed, but depending on what you've done, you might run into trouble.
I'm assuming just basic familiarity with opening the terminal app.
First, install the xcode
development tools if you haven't already (it's a ~200MB download) by typing this into the terminal
xcode-select --install
Then install the Mac package manager homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then add this to your ~/.zshrc
or ~/.zprofile
(try typing open ~/.zprofile
to find it)
eval "$(/opt/homebrew/bin/brew shellenv)"
Start a new terminal session (or type exec $SHELL
) then call
brew install pyenv
Then add this to your ~/.zshrc
or ~/.zprofile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
Then start a new session and run
pyenv install 3.12.2
pyenv global 3.12.2
If the pyenv
install step fails, you may need to install a few more things via brew
by typing
brew install openssl readline sqlite3 xz zlib tcl-tk
Finally, type python
and if it all worked you should see this
Python 3.12.2 <stuff>
Type "help", "copyright", "credits" or "license" for more information.
>>>
If you see something different, it's probably because your zsh profile is sourcing some folder with a system Python and you'll need to edit your profile to not include that.
At this point, you can install a bunch of data tools globally, or use a package manager like virtualenv
or uv
for project-level management and versioning. Personally, I like to install a bunch of core Python data tools globally via the package manager pip
like this
pip install ipython jupyter numpy matplotlib pandas geopandas