0

Hi I cannot seem to understand why even though I just installed Python 3.9.5 (from here https://www.python.org/downloads/), the python3 command runs python 3.8.2 on the terminal, shown below.

This is my first time installing python on my Mac (macOS Big Sur).

MacBook-Air ~ % python --version
Python 2.7.16
MacBook-Air ~ % python3 --version
Python 3.8.2

How can I run what I actually installed, which is python3.9.5?
I appreciate your help.

bisuke
  • 219
  • 3
  • 13

1 Answers1

1

You should remove the current link and add a new symbolic link

unlink /usr/local/bin/python
ln -s /usr/local/bin/python3.9 /usr/local/bin/python

If you also want to be able to run Python 3.9.5 by calling python3 you can do so either as above or by updating your bash profile.

Inside ~/.bash_profile simply add the following line:

alias python3='/usr/local/bin/python3.9'

and finally reload it

source ~/.bash_profile

You should now get

python3 --version
Python 3.9.5
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
  • Thank you. But I don't understand why it run python 3.8 when I didn't even install this.. does it come embedded with python 3.9? – bisuke May 14 '21 at 15:40
  • 1
    @bisuke I assume you already had Python 3.8 installed. – Giorgos Myrianthous May 14 '21 at 15:40
  • Thank you. For the first solution I got an error on terminal "unlink: /usr/bin/python: Operation not permitted". But I tried the second one - I edited my .zprofile instead and it worked. ! – bisuke May 14 '21 at 16:12