brew install python or brew info python output mentions:

Unversioned symlinks python, python-config, pip etc. pointing to python3, python3-config, pip3 etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin

So running, as root (for Bash (executable bash), use the ~/.bash_profile file):

echo 'export PATH=/opt/homebrew/opt/[email protected]/libexec/bin:$PATH' >> ~/.zprofile
source ~/.zprofile

gets you those symlinks created by Homebrew, python=python3, pip=pip3, etc.

python --version

Output:

Python 3.9.10

And:

pip --version

Output:

pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Answer from Callum M on Stack Overflow
🌐
Homebrew
docs.brew.sh › Language-Runtimes-and-Packages
Homebrew Documentation: Language Runtimes and Packages
Use brew install when Homebrew provides the runtime or application you need. Use each language’s project environment and lock file for project dependencies. Avoid running language package managers with sudo or changing ownership of system-managed ...
🌐
Homebrew
formulae.brew.sh › formula › python@3.14
Homebrew Formulae: python@3.14
Bottle (binary package) installation support provided for: Current versions: Other versions: Depends on: Depends on when building from source: Uses from macOS: bzip2, expat (since macOS Sequoia), libedit, libffi, ncurses · Binaries: idle3.14, pip3.14, pydoc3.14, python3.14, python3.14-config, wheel3.14 ·
Discussions

What are your thoughts on Homebrew for getting Python3 up and running on a Mac? And what is your preferred method on your machine?
I install Python from Python.org then install PyCharm. Off I go. More on reddit.com
🌐 r/learnpython
52
96
September 20, 2021
How to make macOS use the Python interpreter installed by Homebrew - Stack Overflow
On my system, Python version number is part of the path directory and I had a couple of versions of python installed via homebrew so I needed to choose one to represent python3 in bash profile. 2021-11-14T23:18:19.43Z+00:00 ... @adamlogan I have updated answer to include brew info python which ... More on stackoverflow.com
🌐 stackoverflow.com
homebrew - How to make python 3.11 my default python3 with brew - Ask Different
I like new software and I noticed that 3.11 is available in brew, so I have installed it: brew install python@3.11 I can get a repl by running python3.11, but if I run python3 I still get python 3... More on apple.stackexchange.com
🌐 apple.stackexchange.com
November 9, 2022
How can I install a previous version of Python 3 in macOS using homebrew? - Stack Overflow
How will this affect or interact with packages in Homebrew that rely on the default python3 interpreter? 2018-07-22T22:31:17.213Z+00:00 ... In any case, a Python depending applications (installed with brew or not) will look for a python3 executable in the applications path, and you will have ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › starting › install3 › osx
Installing Python 3 on Mac OS X — The Hitchhiker's Guide to Python
$ brew install python · This will take a minute or two. Homebrew installs pip pointing to the Homebrew’d Python 3 for you. At this point, you have the system Python 2.7 available, potentially the Homebrew version of Python 2 installed, and ...
Top answer
1 of 7
84

brew install python or brew info python output mentions:

Unversioned symlinks python, python-config, pip etc. pointing to python3, python3-config, pip3 etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin

So running, as root (for Bash (executable bash), use the ~/.bash_profile file):

echo 'export PATH=/opt/homebrew/opt/[email protected]/libexec/bin:$PATH' >> ~/.zprofile
source ~/.zprofile

gets you those symlinks created by Homebrew, python=python3, pip=pip3, etc.

python --version

Output:

Python 3.9.10

And:

pip --version

Output:

pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
2 of 7
38

If you want to install Python 3 using Homebrew:

brew install python3

Output:

==> Downloading http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python3-3.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python3/3.3.0 --enable-ipv6 --datarootdir=/usr/local/Cell
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0/share/python3
==> Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.35.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/pip-1.3.1.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Caveats
Homebrew's Python3 framework
  /usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework

Distribute and Pip have been installed. To update them
  pip3 install --upgrade distribute
  pip3 install --upgrade pip

To symlink "Idle 3" and the "Python Launcher 3" to ~/Applications
  `brew linkapps`

You can install Python packages with
  `pip3 install <your_favorite_package>`

They will install into the site-package directory
 /usr/local/lib/python3.3/site-packages
Executable python scripts will be put in:
 /usr/local/share/python3
so you may want to put "/usr/local/share/python3" in your PATH, too.

    See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python

Once installed update your system PATH variable, add the next line to the ~/.bash_profile file:

export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH

And then:

source ~/.bash_profile

Now launch Python:

python3

Output:

Python 3.3.0 (default, Mar 26 2013, 10:01:40)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

You can check the python3 path:

which python3

Output:

/usr/local/bin/python3
🌐
Homebrew
formulae.brew.sh › formula › python@3.9
Homebrew Formulae: python@3.9
Bottle (binary package) installation support provided for: Current versions: Other versions: Depends on: Depends on when building from source: Uses from macOS: bzip2, expat, libffi, libxcrypt, ncurses, unzip · Binaries: 2to3-3.9, idle3.9, pydoc3.9, python3.9, python3.9-config · Known vulnerabilities in the current version: Data from Homebrew/advisory-database. Run brew vulns python@3.9 for a live check.
Find elsewhere
Top answer
1 of 3
40

Note: This applies to any versioned Python installation with Homebrew

After installing Python 3.11, you are given the location of the bin folder with Python 3.11:

==> Caveats
Python has been installed as
  /usr/local/bin/python3.11

Unversioned and major-versioned symlinks `python`, `python3`, `python-config`, `python3-config`, `pip`, `pip3`, etc. pointing to
`python3.11`, `python3.11-config`, `pip3.11` etc., respectively, have been installed into
  /usr/local/opt/[email protected]/libexec/bin

You can add this folder to be first in your PATH and python or python3 will pick up Python 3.11 (since those are in the folder):


So: add the following line to ~/.zshrc:

export PATH="$(brew --prefix)/opt/[email protected]/libexec/bin:$PATH"

brew --prefix ensures that the correct path is used, regardless of where your brew install resides.

2 of 3
18

On macOS Ventura & Sonoma on Apple Silicon

To install homebrew's version of python3:

brew install python3

This installs brew's version of python3.x but does not override the the link to macOS's version of python3 when you use the python3 command. You can confirm which python3 is being used with the which python3 command. Now, you have two primary options here:

  1. You can unlink the system default's python3 and relink python3 to the homebrew version (see kraspa11's answer)
  2. You can simply add an alias for python3 in your ~/.zshrc file which can point to brew's version instead (I prefer this because it results in fewer edits to system defaults).

If you prefer option #2:

Open up ~/.zshrc with nano ~/.zshrc or your desired editor. BTW, if you want to see "hidden" files/folders in your /Users/[username] folder where .zshrc resides, open your user folder in finder and press ⇧ Shift + ⌘ Command + . (period). This will show/hide all hidden files and folders in your Finder.

At the end of the .zshrc file, add the following lines:

# ensure "python3" command uses homebrew's version of python3
alias python3=/opt/homebrew/bin/python3
# OPTIONAL: ensure "python" command uses homebrew's version of python3
alias python=/opt/homebrew/bin/python3

I use /opt/homebrew/bin/python3 instead of /opt/homebrew/opt/[email protected] so if/when you update your version from 3.11 to 3.12 and so on, your aliases should always work (until version 4).

Now, save and close your edited .zshrc file. To refresh your terminal to use the new alias(es), enter:

source ~/.zshrc

To ensure that your commands are pointing to the brew version of python3:

which python3 should respond: python3: aliased to /opt/homebrew/bin/python3

and

which python should respond: python: aliased to /opt/homebrew/bin/python3

NOTE: I have only tested all of the above on Apple silicon macOS Sonoma (which is in developer beta, but should be functionally the same as Ventura).

🌐
Mac Install Guide
mac.install.guide › python › brew
Brew Install Python · Mac Install Guide
February 25, 2024 - $ brew install python ==> Fetching downloads for: python@3.15 . . . ==> Installing python@3.15 dependency: openssl@4 (4.0.3) . . . ==> Installing python@3.15 ==> Pouring python@3.15--3.15.0.arm64_tahoe.bottle.tar.gz ==> /opt/homebrew/Cellar...
Top answer
1 of 9
270

Short Answer

To make a clean install of Python 3.6.5 use:

brew unlink python # ONLY if you have installed (with brew) another version of python 3
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

If you prefer to recover a previously installed version, then:

brew info python           # To see what you have previously installed
brew switch python 3.x.x_x # Ex. 3.6.5_1

Long Answer

There are two formulas for installing Python with Homebrew: python@2 and python.
The first is for Python 2 and the second for Python 3.

Note: You can find outdated answers on the web where it is mentioned python3 as the formula name for installing Python version 3. Now it's just python!

By default, with these formulas you can install the latest version of the corresponding major version of Python. So, you cannot directly install a minor version like 3.6.

Solution

With brew, you can install a package using the address of the formula, for example in a git repository.

brew install https://the/address/to/the/formula/FORMULA_NAME.rb

Or specifically for Python 3

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/COMMIT_IDENTIFIER/Formula/python.rb

The address you must specify is the address to the last commit of the formula (python.rb) for the desired version. You can find the commint identifier by looking at the history for homebrew-core/Formula/python.rb

https://github.com/Homebrew/homebrew-core/commits/master/Formula/python.rb

Python > 3.6.5

In the link above you will not find a formula for a version of Python above 3.6.5. After the maintainers of that (official) repository released Python 3.7, they only submit updates to the recipe of Python 3.7.

As explained above, with homebrew you have only Python 2 (python@2) and Python 3 (python), there is no explicit formula for Python 3.6.

Although those minor updates are mostly irrelevant in most cases and for most users, I will search if someone has done an explicit formula for 3.6.

2 of 9
52

I have tried everything but could not make it work. Finally I have used pyenv and it worked directly like a charm.

So having homebrew installed, just do:

brew install pyenv
pyenv install 3.6.5

to manage virtualenvs:

brew install pyenv-virtualenv
pyenv virtualenv 3.6.5 env_name

See pyenv and pyenv-virtualenv for more info.

EDIT (2020/03/19)

I have found using the pyenv-installer easier than homebrew to install pyenv and pyenv-virtualenv direclty:

curl https://pyenv.run | bash

To manage python version, either globally:

pyenv global 3.6.5

or locally in a given directory:

pyenv local 3.6.5

EDIT (2025/12/19)

Just use uv

🌐
Substack
mettlesome.substack.com › mettlesome // raphaël’s substack › the right way to install python on a mac
The right way to install Python on a Mac
February 7, 2024 - Next, install HomeBrew — the open source package manager for mac. Browse to · https://brew.sh/ and copy and run the command at the top of the page.
🌐
Ahmad Awais
ahmadawais.com › home › python not found on macos | install python with brew | fix $path
Python not found on MacOS | Install Python with brew | Fix $PATH
June 12, 2023 - Learn how to update Python on macOS and make Python 3.11 the default version. Follow step-by-step instructions to install Python via Homebrew, configure the $PATH variable, and start a new login shell. Say goodbye to "command not found: python" and enjoy the latest Python version on your Mac.
🌐
Jason Murray
jasonmurray.org › posts › 2020 › python3macos
Installing python3 on macOS using Homebrew (don't use the system version)
May 17, 2020 - I recommend avoiding the version ... One of the easiest ways to install and manage the latest version of python3, and other software, is to use the Homebrew package manager....
🌐
freeCodeCamp
forum.freecodecamp.org › programming › python
Help with python3 setup on MacOS - Python - The freeCodeCamp Forum
August 8, 2018 - I am trying to use python 3 and pip to install scrapy. I’ve successfully installed it using homebrew, but when I type python at the terminal it is running python 2.7 (installed with the OS). The installation instructions say that if this occurs ensure that the path is corret and that ...
🌐
Stack Overflow
stackoverflow.com › questions › 68806411 › how-to-install-python-3-9-6-using-homebrew-on-mac-m1
installation - how to install python 3.9.6 using homebrew on Mac m1 - Stack Overflow
Im new to programming and stuff and was looking to install python 3.9.6 using home-brew. To do that would I just have to type in brew install python@3.9 into the terminal, or is there some other way?
🌐
Aditya Sharma
adityashrm21.github.io › Installing-Python3
Installing Python3 on Macbook
July 21, 2018 - Follow the instructions if any ... many packages and software using brew easily. By default your Mac should contain a python version which you can check by using: ... For me it gives “Python 2.7.10”. Now to install python3 simply use the command:...
Top answer
1 of 6
16

I have done this sort of thing in two ways - however both do not coexist with homebrew although I suspect there should be a way similar to the macports one.

General package manager

The first is using Macports as the package manager. There are separate ports for several python versions 2.x and 3.x currently 2.4, 2.5, 2.6, 2.7 and 3.1, 3.2, 3.3 3.4 and 3.5. For example to install 3.4 do sudo port install python34 There is also a python_select port that running it allows you to choose which version of python is run by /opt/bin/python. e,g, to select macports python 2.7 port select --set python python27

Each package manager needs to run as the only package manager otherwise it will be confused with unexpected different versions of libraries and executables on its paths.

From comments the similar homebrew way is given in https://stackoverflow.com/a/4158763/151019 Short answer seems to be brew switch the equivalent to port_select

Python version managers

The other way is install direct from python.org This will install a python into /usr/local/bin I think this installs a python and python3 executable. The issue with Homebrew is that it assumes that things in /usr/local are installed by it and so brew doctor will report these python.org pythons and libraries as issues and as this question shows also the frameworks in /Library will be problematic.

EDIT 8/2018 *** I would now suggest using conda either miniconda or anaconda. This is another package manager but based and mainly meant for python, it also gives the equivalent of python's virtual environments and pyenv (as per other answer) and so each project can be in a different python and different libraries (Macports only switches python version for all projects)

2 of 6
115

For Python in macOS, use pyenv:

brew install pyenv

To install a specific Python version, run:

pyenv install <version>

To select a version for every command run with the current folder:

pyenv local 3.5.0

Note that you must update PATH in your environment to find pyenv's python3 before any other:

PATH="~/.pyenv/shims:${PATH}"

With recent version of OSX(13.X) the path is moved to /etc/paths.d/ Add a file eg: pyenvpath to /etc/paths.d/pyenvpath Add the path to that file.

To list available versions:

pyenv versions

See https://gist.github.com/Bouke/11261620 for more information.

🌐
freeCodeCamp
freecodecamp.org › news › python-version-on-mac-update
How to Install Python 3 on Mac – Brew Install Update Tutorial
April 6, 2021 - This version is included in macOS for compatibility with legacy software. Future versions of macOS will not include Python 2.7. Instead, it is recommended that you transition to using 'python3' from within Terminal. Until Apple decides to set Python 3.x, as the default you're going to have to install it yourself.
🌐
Medium
arafat-azam.medium.com › installing-python-with-brew-in-mac-properly-203db905aae9
Installing Python3 with brew on Mac properly | by Muhammad Arafat Azam | Medium
March 28, 2022 - Installing Python3 with brew on Mac properly Overwriting Mac’s default python Update: Since macOS Monderey 12.3, python2 will not be shipped with the OS. This article is applicable for macOS …