A brew upgrade upgraded my system Python to Python 3.7. Unfortunately, Python 3.7 breaks other software I need to use (including but not limited to Ansible). I imagine these problems will be worked out in the next week or so, but in the meantime, I'd like to rollback to Python 3.6.5.x

A brew info python shows that previous versions are still installed and not purged:

➜ brew info python
python: stable 3.7.0 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
/usr/local/Cellar/python/3.6.5 (4,825 files, 100.8MB)
  Poured from bottle on 2018-03-31 at 20:21:57
/usr/local/Cellar/python/3.6.5_1 (4,788 files, 99.9MB)
  Poured from bottle on 2018-06-20 at 16:00:26
/usr/local/Cellar/python/3.7.0 (4,869 files, 103.3MB)
  Poured from bottle on 2018-07-01 at 19:30:37
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb

Various brew link and brew install commands that are suggested by other sites don't seem to work:

➜ brew link python@3.6.5
Error: No such keg: /usr/local/Cellar/python@3.6.5
➜ brew link python@3.6.5_1
Error: No such keg: /usr/local/Cellar/python@3.6.5_1
➜ brew install python@3.6.5
Error: No available formula with the name "python@3.6.5" 
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

If you still have the previous versions available, you can just use

brew switch python 3.6.5_1
  • 1
    Give me a couple of months I'll be ready to switch to 3.7. When that day comes, how do I undo this brew switch ... command to get back to 3.7? – Peter Bengtsson Jul 6 '18 at 17:12
  • How does this differ to creating a virtual environment attached to Python 3.6.5? – jmh Jul 22 '18 at 17:26
  • @jmh for some reason my 3.6.5 virtual environments broke when I used Homebrew to update to 3.7, and I haven't quite figured out why. Of course, one of the reasons I made virtual environments in the first place was to avoid that issue. Switching back fixed it. Since nothing in 3.7 is critical for me, I'm just sticking with 3.6.5 for the moment. – knilsilooc Jul 24 '18 at 17:40
  • 2
    I realized that the reason for the above is that Python's built-in venv creates symlinks, which break when going from Python 3.6.x to 3.7.x. Creating venvs with python3 -m venv --copies venv copies the Python files instead of creating symlinks, which prevents them from breaking when upgrading your Python version. – knilsilooc Aug 1 '18 at 14:36
  • 4
    Error: python does not have a version "3.6.5_1" in the Cellar. python installed versions: 3.7.0 – mrgloom Nov 1 '18 at 15:11

If you don't have previous version to switch to, you can install from previous formula this way:

$ brew unlink python
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
  • I think it would be useful if you also explain what brew unlink python does. – nbro Oct 4 '18 at 8:11
  • Moreover, you should emphasize that this doesn't apparently remove your current Python 3.7 version, and that later you can switch back to it (using e.g. what is suggested https://apple.stackexchange.com/a/329192/90775). – nbro Oct 4 '18 at 8:12
  • 5
    If you get an issue about a recursive dependence, this can be bypassed by ignoring dependencies: brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb. – Eric Wiener Jan 29 at 18:22
  • If --ignore-dependencies doesn't work due to sphinx, comment out the dependency in sphinx and reinstall sphinx as described here: pyimagesearch.com/2019/01/30/… – thadk Apr 13 at 1:00

Two options

To recover a previously installed Python version:

brew switch python 3.x.x_x # Ex. 3.6.5_1

Use brew info python to see what you have previously installed

To make a clean install of Python 3.6.5 use:

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

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.


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


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.


You can temporarily backdate homebrew-core and set the HOMEBREW_NO_AUTO_UPDATE variable to hold it in place:

cd `brew --repo homebrew/core`
git checkout f2a764ef944b1080be64bd88dca9a1d80130c558
brew install python
brew install vim --with-python

I don't recommend permanently backdating homebrew-core, as you will miss out on security patches, but it is useful for testing purposes.

You can also extract old versions of homebrew formulae into your own tap (tap_owner/tap_name) using the brew extract command:

brew extract python tap_owner/tap_name --version=3.6.5
  • Making your own tap or finding someone who has automated maintaining the 3.6 and other series with updates is definitely the best way to go. If they do it properly you can have a fully qualified version and link it with brew link python@3.6.x. Though pyenv is another option as well. – dragon788 Mar 19 at 16:12

Following Step #3: Downgrade Python 3.7 to Python 3.6 on macOS Mojave here worked for me: https://www.pyimagesearch.com/2019/01/30/macos-mojave-install-tensorflow-and-keras-for-deep-learning/


I'm not an expert on this, but had the same issue. This is what worked for me: $ brew unlink python $ brew uninstall --ignore-dependencies python3 $ brew uninstall pipenv then from https://www.python.org/downloads/ installed python 3.6.6 $ brew install pipenv

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .