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 [email protected]
Error: No such keg: /usr/local/Cellar/[email protected]
➜ brew link [email protected]_1
Error: No such keg: /usr/local/Cellar/[email protected]_1
➜ brew install [email protected]
Error: No available formula with the name "[email protected]" 
==> 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.
  • 10
    For those who don't have 3.6.5_1 installed, there is a way to get it via brew: stackoverflow.com/a/51125014/760905 Jul 3, 2018 at 10:24
  • There is a python version 3.7.1. maybe that fixes your problems.
    – Natsfan
    Nov 25, 2018 at 21:00
  • For those landing here looking for a way to use an arbitrary older python version, try github.com/pyenv/pyenv (which you can install with brew)
    – Peter W
    Nov 6, 2020 at 4:09

9 Answers 9


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

brew switch python 3.6.5_1
  • 2
    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? Jul 6, 2018 at 17:12
  • 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, 2018 at 14:36
  • 13
    Error: python does not have a version "3.6.5_1" in the Cellar. python installed versions: 3.7.0
    – mrgloom
    Nov 1, 2018 at 15:11
  • 2
    Once you've rolled back consider brew pin python to keep it there. This will prevent Homebrew from upgrading it when you do a brew upgrade.
    – Ian C.
    Sep 14, 2019 at 22:28
  • 1
    Update: HomeBrew has removed the switch command, so this no longer will work. See this link for the discussion around removing the option
    – TMarks
    Apr 23, 2021 at 1:35

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

$ brew unlink python

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

If you are getting:

# --ignore-depeError: python contains a recursive dependency on itself:
  python depends on sphinx-doc
  sphinx-doc depends on python

...then run:

$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

...instead of the last command.

If then you will get the following error when you do pip3 install after such installation:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

...then a workaround may be to install its dependencies first (everything except sphinx-doc)

$ brew install pkg-config gdbm openssl readline sqlite xz

Notice that it needs openssl and NOT [email protected] which is a latest dependency in homebrew python 3.7.*.

  • 1
    I think it would be useful if you also explain what brew unlink python does.
    – user90775
    Oct 4, 2018 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).
    – user90775
    Oct 4, 2018 at 8:12
  • 9
    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. Jan 29, 2019 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, 2019 at 1:00
  • Error: python contains a recursive dependency on itself: python depends on sphinx-doc sphinx-doc depends on python Aug 22, 2019 at 14:30

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.


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/


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 [email protected]. Though pyenv is another option as well.
    – dragon788
    Mar 19, 2019 at 16:12

In my case I have opted out of brew version and used asdf to manage multiple Python versions.

Assuming you already have asdf installed:

brew unklink python
asdf plugin-add python
asdf install python 3.6.9 && asdf global python 3.6.9

For anyone landing on this page, adding to rinat.io's answer above: brew has undergone changes and extracting old formulas is a bit of a pain. Refer to this issue https://github.com/kelaberetiv/TagUI/issues/635 for resolving any OpenSSL related issues with pip.


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


I could not find the correct solution to a similar problem of mine (with vim quitting unexpectedly) to quickly rollback to the previous version of python.

Here is the oneliner I often use. In this case, it would be:

Disclaimer: some programs from brew manager may require other versions of python due to their own dependencies.

brew update && brew install [email protected]_1 && brew unlink [email protected] && brew link [email protected]_1 --force && brew cleanup
  • That links to the newer python and removes the older one which is the opposite of the question
    – mmmmmm
    Feb 16, 2021 at 14:18
  • thanks, for pointing it out. my bad, spelling mistake.
    – Egel
    Feb 16, 2021 at 14:28

You must log in to answer this question.

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