Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to default Python3.8 on my Mac using Homebrew?

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

brew search python ==> Formulae app-engine-python   gst-python          python ✔            [email protected] ✔ 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 
like image 716
Tack_Tau Avatar asked Feb 28 '20 13:02

Tack_Tau


People also ask

How do I make python3 8 default on Mac?

Open the terminal (bash or zsh) whatever shell you are using. Install python-3 using Homebrew (https://brew.sh). Look where it is installed. Change the default python symlink to the version you want to use from above.

What is the default version of Python on Mac?

Use Python 3 as the macOS default Python's website has a macOS Python 3 installer we can download and use. If we use the package installation, a python3 fill will be available in /usr/local/bin/.


2 Answers

Here is the solution:

If existing symlinks belong to python 3.7 you should unlink them:
brew unlink python

Basically all you need to do:
brew link --force [email protected]

OR force the link and overwrite all conflicting files:
brew link --force --overwrite [email protected]

OR if needed list all files that would be deleted:
brew link --overwrite --dry-run [email protected]

Thus you can switch to any python version available in the Homebrew repo.

Also check out this answer for pyenv usage

like image 85
Igor Voltaic Avatar answered Oct 09 '22 05:10

Igor Voltaic


Ok, thanks to @gromgit from Homebrew community discussion (https://discourse.brew.sh/t/how-to-default-python-3-8-on-my-mac-using-homebrew/7050)

Here is the solution:

$ brew info [email protected] [email protected]: stable 3.8.1 (bottled) [keg-only] ... ==> Caveats Python has been installed as   /usr/local/opt/[email protected]/bin/python3 ... [email protected] 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 [email protected] first in your PATH run:   echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile  For compilers to find [email protected] you may need to set:   export LDFLAGS="-L/usr/local/opt/[email protected]/lib"  For pkg-config to find [email protected] you may need to set:   export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig" 

I will stick to python (v3.7.6) at this time and wait for seamless upgrade of v3.8.1 in the future releases.

like image 45
Tack_Tau Avatar answered Oct 09 '22 06:10

Tack_Tau