MacOS: How to downgrade homebrew Python?
First, it's generally considered bad practice to rely on system python for user land code if you can avoid it. You need to assume that system utilities require a specific version of system python, and your user land code may then be locked to that python version forever, which is not wise (unless you're writing system utilities, in which case just use /bin/python, but then you wouldn't be asking this question...).
Secondly, I am unclear why you need 2.7.10 instead of 2.7.13. All pythons with the same minor revision number (2.7) should always be compatible. If you needed 2.6, that would be a different story since that's a change in minor version. Code written for 2.7.x should all be compatible.
However, assuming your use case really does require using a specific Python version - getting to an actual solution now - be sure sure you really upgraded system python to begin with. If you enter the command:
which python, do you get
/usr/bin/python (system) or
/usr/local/bin/python (brew installed user-land python). For example,
/usr/bin/python -V gives me 2.7.10 even though
python -V gives me 2.7.13 (via brew).
It's possible that you installed the latest python 2.7.x via
brew which puts
/usr/local/bin/python as a symlink in your
$PATH, or you perhaps have a
python alias pointing somewhere you don't want. Verify your $PATH order.
You can reset your homebrew python by removing it (
brew uninstall python), or by changing the symlink (
ln -s -f /usr/bin/python /usr/local/bin/python). However, using virtualenv removes the need for much of these sorts of gymnastics.
If you want to monkey with prior versions of Python installed via homebrew, this answer should help: How to install older formula using Brew?
One final option: if you absolutely must have a specific python version, pyenv can help.
brew install pyenv
pyenv install 2.7.10
pyenv global 2.7.10
Switching Python version installed by Homebrew
There is an Homebrew known issue related to side by side install of Python 3.8 / 3.9. To workaround, following commands should work for you:
brew unlink firstname.lastname@example.org
brew unlink email@example.com
brew link --force firstname.lastname@example.org
Re-opening your terminal or execute command
rehash can be required to take account the change.
How can I install a previous version of Python 3 in macOS using homebrew?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
There are two formulas for installing Python with Homebrew:
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
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.
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.rbPython > 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.
How to Get the Column Name in Pandas Based on Row Values
How to Read Multiple Lines of Raw Input
Pythonic/Efficient Way to Strip Whitespace from Every Pandas Data Frame Cell That Has a Stringlike Object in It
How to Sort the Letters in a String Alphabetically in Python
How to Convert Base64 String to Image
Getting All Possible Combinations from a List With Duplicate Elements
Regular Expression to Check Whitespace in the Beginning and End of a String
How to Store Python Dictionary in to MySQL Db Through Python
How to Sum Multiple Columns in a Spark Dataframe in Pyspark
How to Get Text from Span Tag in Beautifulsoup
How Best to Insert Nan Values in a Python List by Referring to an Already Sorted List
How to Fix the 403:Insufficient Authentication Scopes Error from Google Analytics User Deletion API
How to Execute Two Commands in Terminal Using Python'S Subprocess Module
Using Condition to Split Pandas Column of Lists into Multiple Columns.
How to Completely Remove Python from a Windows Machine
Tkinter: How to Use Threads to Preventing Main Event Loop from "Freezing"
Calling a Function of a Module by Using Its Name (A String)
Tensorflow - Valueerror: Failed to Convert a Numpy Array to a Tensor (Unsupported Object Type Float)