Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I choose default python homebrew version?

I have all three versions of python 3.10, 3.11 and 3.12 using homebrew. but somehow homebrew defaults to using 3.11 as the default.

when i type which python3, it shows 3.11.6 as the version instead of 3.12. why did it default to 3.11 and how do i change this to 3.12?

I was expecting the latest version 3.12 to be the default.

like image 420
Jack of all trades Avatar asked Jun 14 '26 01:06

Jack of all trades


2 Answers

The issue seems to be in the difference between [email protected] and [email protected] Homebrew Ruby scripts.

3.11 has link_overwrite for python3 which sets a bunch of symlinks in /usr/local/bin/ (which is usually in your $PATH) to use 3.11.

3.12 lacks this and so your shell is not seeing them.

You can rectify this either by modifying your $PATH as in the other reply, or replacing the symlink manually:

cd /usr/local/bin && rm python3 && ln -s ../Cellar/[email protected]/3.12.1/bin/python3.12 python3
like image 107
Michael Oliver Avatar answered Jun 15 '26 13:06

Michael Oliver


Edit 2024-02-25: About four days ago, the below PR was merged. I believe brew install python should now install Python 3.12.


python3 in Homebrew won't point at 3.12 until this PR is merged. AFAIK Homebrew don't switch the default python3 to the latest version until all the Python software that Homebrew packages are confirmed to work with the new version.

If you really need python3 to point at 3.12 globally right now, I personally like @Iskander14yo's suggestion to use pyenv (above).

like image 39
Dale Avatar answered Jun 15 '26 13:06

Dale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!