MacOS: How to downgrade homebrew Python?

Viewed 50031

I'm running MacOS Sierra 10.12.4 and I've realized that homebrew python was upgraded to version 2.7.13. How can I switch back to 2.7.10?

5 Answers

You can switch versions with brew switch. For instance I just downgraded Python 3.7.0 to 3.6.5 like this:

brew switch python 3.6.5

Unfortunately, the brew versions command has been deprecated, and it's currently pretty complicated to locate the available versions. I'd love to hear a simple solution to this. Meanwhile, if you know the version you want to switch to, try the above command.

I agree with the answers here that virtualenvs are a good idea, but having the version of Python you need in homebrew is also a good idea. The way my virtualenvs were created, bin/python was a symlink to /usr/local/bin/python, so things broke when Python was updated via homebrew.

Download python 3.6.0 from https://www.python.org/downloads/release/python-360/

Install it as a normal package.

Run cd /Library/Frameworks/Python.framework/Version

Run ls and all installed Python versions will be visible here.

Run sudo rm -rf 3.7

Check the version now by python3 -V and it will be 3.6 now.

There is no need to downgrade python as you can use both on your system.

Places where you want your file to compile with python 2-x.

python2 or python2-x filename.py

and where you need python 3

python3 or python3-x filename.py

The default usage of python will lead to use the latest version, and downgrading to a particular version is a lot of headache as it is not direct as python is not made backward compatible from 3-x to 2-x.

Related