Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use python3.10 with brew on mac?

I installed python3.10 by using brew install [email protected] But here's what happened.

$python3.10
zsh : command not found : python3.10

$which python3.9
/usr/local/bin/python3.9

$ls -al /usr/local/bin/python*
lrwxr-xr-x  1 host  admin  39 Mar 30 12:17 /usr/local/bin/python3 -> ../Cellar/[email protected]/3.9.12/bin/python3
lrwxr-xr-x  1 host  admin  46 Mar 30 12:17 /usr/local/bin/python3-config -> ../Cellar/[email protected]/3.9.12/bin/python3-config
lrwxr-xr-x  1 host  admin  41 Mar 30 12:17 /usr/local/bin/python3.9 -> ../Cellar/[email protected]/3.9.12/bin/python3.9
lrwxr-xr-x  1 host  admin  48 Mar 30 12:17 /usr/local/bin/python3.9-config -> ../Cellar/[email protected]/3.9.12/bin/python3.9-config

$ls /usr/local/Cellar/python*
/usr/local/Cellar/[email protected]:
3.10.2

/usr/local/Cellar/[email protected]:
3.9.12

So it seems like there is a python3.10 installed on Cellar but there's no symlink in /usr/local/bin for it. When I installed python3.9, I didn't have to setup those things. How can I add&use python3.10? Creating symlink on my own to /usr/local/bin is the last thing I want to do. I hope there's some command for brew to make this done.

like image 685
47-54-50-56 Avatar asked Sep 16 '25 22:09

47-54-50-56


1 Answers

When you have a previous version of Python installed, brew won't link the new version by default.

To fix this, run brew link --overwrite [email protected]

You can also do a dry-run of this first:

brew link [email protected]

You may need to add the --overwrite flag if you have previously linked versions of python

brew link --overwrite [email protected]

You can test the commands by adding the --dry-run flag.

$ brew link --dry-run [email protected]
Would link:
/usr/local/bin/2to3
#...
/usr/local/bin/python3.10
#...

When /usr/local/bin/python3.10 is linked, you can then use python3.10 to invoke that version of python.

like image 148
sytech Avatar answered Sep 18 '25 19:09

sytech