John
John

Reputation: 115

brew installs latest python3 but python3 not updated?

Hello I'm trying to upgrade my python from macos

I enter command 'brew upgrade python3' and it tells me the latest version is installed (Warning: python3 3.9.1_8 already installed)

but then when I type 'python3 -V' it returns 'Python 3.6.1'

and when I try to 'brew link --overwrite [email protected]' the operation proceeds successfully but there is still no change.

What am I missing? Why am I not able to use Python3.9?

Upvotes: 1

Views: 3407

Answers (2)

CryptoFool
CryptoFool

Reputation: 23079

I highly recommend that you install and use pyenv. It is somewhat standard way of managing multiple Python versions on your Mac. I have 4 different Python versions, and switch from one to the other with ease. It can do a lot more than just set your global Python version. Check it out: https://github.com/pyenv/pyenv. It can be installed with brew install pyenv.

Upvotes: 1

Ouss
Ouss

Reputation: 3855

Most likely the PATH variable in your environment is not configured correctly and the shell is finding the wrong python3.

You can check for the path to the current python3 command using:

which python3

Most likely the output will not be pointing at the brew installation that is usually:

/usr/local/bin/python3

If that was the case check the PATH variable in your environment using:

echo $PATH

or:

env | grep PATH

and check whether /usr/local/bin is present in the PATH variable and that it has precedence over the folder where your current python3 is located.

Change it by edited the .profile file in your home directory by adding:

export PATH="/usr/local/bin:$PATH"

Upvotes: 1

Related Questions