How to default Python 3.8 on my Mac using Homebrew

Hi, I have updated my python 3 to the latest version 3.8:

brew search python
==> Formulae
app-engine-python   gst-python          python ✔            python@3.8 ✔
boost-python        ipython             python-markdown     wxpython
boost-python3       micropython         python-yq

==> Casks
awips-python               kk7ds-python-runtime       mysql-connector-python

But when I check the python3 version on my mac it still shows 3.7:

python3 --version

Python 3.7.6

how can I default python3 to the latest 3.8 version using Homebrew ?

Edit:
When I tried to use brew switch, it tells me I only installed python 3.7.6, but with last brew upgrade I’m pretty sure that python3.8.1 is installed with Homebrew

brew switch python 3.8.1
python does not have a version "3.8.1" in the Cellar.
python's installed versions: 3.7.6_1

There’s a much less disruptive way, that’s already documented in the python@3.8 formula:

$ brew info python@3.8
python@3.8: stable 3.8.1 (bottled) [keg-only]
...
==> Caveats
Python has been installed as
  /usr/local/opt/python@3.8/bin/python3
...
python@3.8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have python@3.8 first in your PATH run:
  echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.bash_profile

For compilers to find python@3.8 you may need to set:
  export LDFLAGS="-L/usr/local/opt/python@3.8/lib"

For pkg-config to find python@3.8 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig"

Set your PATH (and LDFLAGS and PKG_CONFIG_PATH if needed) as described above, and no switching/relinking is needed.

You could alternatively brew unlink python and brew link --force python@3.8, but that “forcing” option is a big hint that subsequent things may not go well.

2 Likes

Ok, will this conflict with the Python 3 kernel on Jupyter Notebook ?

Currently the Python 3 kernel running on Jupyter Notebook is Python3.7.6

Edit:
And by the way I have all the python3 packages installed in the /usr/local/lib/python3.7/site-packages directory, will all these packages be safely preserved if I change Python3.7.6 to Python3.8.1 ?

You’d have to try it to find out.

Not a Python guru, but the answer’s almost certainly no, because python@3.8 is a completely different entity from python, not just a different version of the same package. You’d have to change your PATH first, then reinstall your Python3 stuff.

I’d suggest sticking to python (v3.7.6) unless you absolutely must use the bleeding edge, because it’ll probably be upgraded seamlessly to v3.8 in the near future.

1 Like

Got it, I will stick to my current Python3.7.6.

Thanks a lot !

So i’m reading back on the issue that Tick-tack Tony Tao was having and I don’t think his concern is really that that far afield. For example. Yes python 3.8 is keg only. If homebrew is making 3.7.7 the default one to use, the it should make it *the default python to use. For example, I have boost-python installed in the Cellar for 2.7 and 3.8. why no 3.7? Homebrew also symlinks 3.7 all over the damn place with seemingly no concept of boundaries or respect for other python versions. I mean isn’t there a way to universalize this stuff? We’re in the 21st century people.

My problem is this, if 3.7.7 is the default homebrew python provided, where can I get the python supported packages that seem to be missing from 3.7.7 i.e. boost-python-3.7.7. I’ve been forced to sym-link some packages that are keg only becasue my system config is not optimized for the build I am attempting. Thanks.

There’s less and less packages depending python 3.7 as they are migrated over. A lot of the remaining packages are broken however and that makes progress slow.

This is more due to python 2 and 3 existing alongside one another for 11 years. There’s just a lot of software that’s broken with python 3.8 (that finally removed some compatibility stuff). The best way for this to get faster is to encourage upstream projects to test with the latest python version as well as the stable ones so homebrew maintainers don’t have to patch all software.

We’re indeed putting quite some effort into refuting peoples claims about analytics. If people could just check what we collect and stop bringing it up with every issue they dislike, a lot more maintainer time could be spend maintaining the project.

3 Likes

I estimate the work we provided for this python 3.8 migration between 500 and 1000 man-hours since it has started. All this for free. Do you still think we do not provide enough effort? :smiley:

3 Likes

@schlamar you should go to Patreon right now. Show some appreciation for the free work you benifit from.

My guess after looking at a comment like that is you’ve never been to Patreon. Prove me wrong, please.

I have nothing to do with homebrew (besides supporting and benifiting from them), but that was infuriating to read. Have some integrity, please.