Unable to downgrade python version in macos using Homebrew - python

Facing issues when trying to downgrade python version from 3.7.3 to 3.6.5_1. I have did lot of research before reaching to stackoverflow family and all of them were suggesting the same resolution steps that i have tried as below, but found no luck. I looking for the python 3.6.5_1 version because Python 3.7 is unsupported by Keras/TensorFlow and thus are not a good choice for OpenCV either:
Option 1:
brew unlink python
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Error: Calling Installation of python from a GitHub commit URL is disabled! Use 'brew extract python' to stable tap on GitHub instead.
Option 2:
brew switch python 3.6.5
Error: python does not have a version "3.6.5" in the Cellar.
after couple of tries I realized that it is problem with the git url that homebrew has it to get python 3.6.5_1 version and that would have changed or the commit url might not be the latest.
macOS version : Catalina 10.15.6
So seeking your guidance and suggestions on how to solve this problem. Also please let me know if missed any info that is required to post here(which could've helped in solving the problem)
Thanks in advance

using brew install sashkab/python/python#3.6 works. credit to #Jean-Pierre Matsumoto.

what has worked for me (of course you can replace 3.7 with any valid python version like 3.5, 3.6, 3.8, 3.9, etc)
brew install python#3.7
and since brew switch is no longer supported you can simply run
brew unlink python3
brew link python#3.7
now you can verify python3 version as desired
python3 --version
you can use link and unlink in the example above to switch versions and/or to setup virtualenvs with specific python versions
virtualenv --python=python3.7 PATH_TO_NEW_ENV

Related

"brew install python" installs 3.9. Why not 3.10?

My understanding is that "brew install python" installs the latest version of python. Why isn't it pulling 3.10? 3.10 is marked as a stable release.
I can install 3.10 with "brew install python#3.10 just fine and can update my PATH so that python and pip point to the right versions. But I am curious why "brew install python" its not installing 3.10.
My other understanding is that 3.10 is directly compatible with the M1 chips so that is why I want 3.10.
Please let me know if I am mistaken.
As Henry Schreiner have specified now Python 3.10 is the new default in Brew. Thx for pointing it
--- Obsolete ---
The "python3" formula is still 3.9 in the brew system
check the doc here:
https://formulae.brew.sh/formula/python#3.9#default
The latest version of the formula for 3.9 also support apple silicon.
If you want to use python3.10 you need to run as you described brew install python#3.10
The reason why 3.9 is still the official python3 formula is that generally user using the vanilla python3 are not looking for the latest revision but the more stable. in some months the transition will done.
Python#3.10 is currently keg-only, which means 3.10 is not the default version yet. You can see a message stating this by typing on the terminal: brew info python#3.10:
python#3.10 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
The migration tasks are not yet all done as of July 2022. You can see the latest situation and the details on GitHub: https://github.com/Homebrew/homebrew-core/pull/87075

How to use Homebrew to upgrade to a specific Python version?

I've been using Homebrew to install various packages on my Mac. Currently I have Python 2.7.13 installed via Homebrew but I'd like to upgrade to Python 3.5.x, not 3.6 which is brew's current default. At first, I just tried upgrading to Python 3:
brew install python3
Brew said "python 2.7.13 is already installed. To upgrade to 3.6.5, run brew upgrade python" which isn't the version I want.
I then tried to search to see what versions of Python brew has available:
brew search python
Now Homebrew tells me, "If you meant "python" specifically: It was migrated from caskroom/cask to homebrew/core."
I then looked at homebrew-core on Github but it doesn't appear to provide any instructions on how to do what I want to do. Does anyone know how to now display a list of Python versions that one can install using Homebrew and what command to use to install a specific version?
There are several discussions of this, here and elsewhere. There is no direct way to do what you want. The recommended approach is to install pyenv via brew, and use pyenv to manage the different versions of Python on your system.
The github repo has a very detailed and clear guide on usage:
https://github.com/pyenv/pyenv
To see the version of python use python --version, and for upgrade use sudo apt-get upgrade python.
I used this, and it's worked

Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)

How to upgrade easy_install to easy_install-3.4?

I just upgraded python to version 3.4. However, the pip wasn't installed by default for some reason. So I'm trying to install pip using the command "sudo easy_install pip." But when I typed the command, it gives me an error:
python version 3.4.0 can't run /usr/bin/easy_install. Try the alternative(s):
/usr/bin/easy_install-2.5 (uses python 2.5)
/usr/bin/easy_install-2.6 (uses python 2.6)
/usr/bin/easy_install-2.7 (uses python 2.7)
Run "man python" for more information about multiple version support in
Mac OS X.
So, I looked through online to find out how to update easy_install to version 3.4, but I could not find any source. Does anyone know how to update the version of easy_install?
To cut to the problem of pip, you can just use the get-pip.py script from the pip site.
Download the file: https://raw.github.com/pypa/pip/master/contrib/get-pip.py
And then run python get-pip.py, provided your account has administrator access.
Source: http://pip.readthedocs.org/en/latest/installing.html#install-or-upgrade-pip
I know this question is a bit old, but I just upgraded to python 3.4.2 on my Mac and running 'pip install ' wasn't working for me either.
I found this link: https://www.python.org/dev/peps/pep-0439/
which says to use 'pip3' instead of 'pip' and this worked perfectly for me.

How to install Python25 on my mac with Homebrew

I'm new to Mac's and Python. I want to install an older version of Python (2.5) on to the Mac (OS X 10.8.1).
I'm using homebrew as it's newer than MacPorts and I don't know enough to choose between them.
Following instructions I have installed Rails, mySQL, budle, pow - all sorts of stuff, but when I use the same technique to install python 2.5 it doesn't work.
I tried:
Axolotl:.pow neil$ brew search python25
homebrew/versions/python25
Axolotl:.pow neil$ brew install python25
Error: No available formula for python25
Axolotl:.pow neil$ brew install homebrew/versions/python25
Error: No available formula for python25
Where am I going wrong? Thanks.
python25 is available in the Homebrew-versions tap:
$ brew tap homebrew/versions
$ brew install python25
I think the brew tap homebrew/versions tip is no longer valid...
I have added that to my Homebrew, however it appears to point to this repo: https://github.com/Homebrew/homebrew-versions
...and that does not contain any Python versions.
$ brew search python25
No formula found for "python25".
So if you want to install a specific version other than latest 2.7.x or 3.x.x you need a different method, what worked for me is:
brew install pyenv
(complete the install instructions)
pyenv install 2.5
You can then switch Python versions either globally (default) or just in current shell session, see: https://github.com/yyuu/pyenv
Instead of using brew to install into the entire system a really old version of Python; consider using pythonbrew instead. It will isolate the python install - a bit like virtual environment, but for Python itself.
You're not doing anything wrong, I'm afraid you're just out of luck. Have a look on the list of formulae available: no Python2.5.
There could be a workaround: copy the python.rb gem and edit the lines mentioning a version number, switching from 2.7 to 2.5. Careful with line 31 (the sha1 signature), you'll want to edit that too.

Categories

Resources