Mac Os

Don’t update the standard python. It will break lots of things. Instead use something like pyenv to manage your python versions:

You can, in addition, use pyenv-virtualenv to manage your virtual enviornments.

Pyenv

brew update
brew install pyenv

For Zsh:

MacOS, if Pyenv is installed with Homebrew:

These add lines to .zshrc

alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

and add this line to .zprofile

eval "$(pyenv init -)"

This will make it so that when you instantiate a .python-version file your shell will activate it for you. This also works nicely with sublime if you have terminus installed.

To list the python versions you can install:

pyenv install -l

To python install versions:

$ pyenv install 3.10.3

To check installed versions run:

$ pyenv versions

pyenv-virtualenv

Use this to create virtual environments.

install:

$ brew install pyenv-virtualenv

Usage

Install

$ pyenv virtualenv 3.10.3 environment-name

to install using default pyenv run:

pyenv virtualenv envrionment-name

You can make pyenv-virtualenv auto activate by creating a .python-version file with just the name of the virtualenv you created. You can do this by automatically by running:

pyenv local environment-name

I also have a script that will automate most of this process here

Updated: