Reputation: 35
I installed python 3.6 before and installed python 3.7.4 today. When I type python3
in command, it opens python 3.6, I want to change it to python 3.7.4.
which python3
shows /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
,
but the link in /usr/local/bin/
is :
python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
so is the case of pip3
. why? ?
How can I change which python3
to python 3.7.4? I don't want to use alias
.
I use MacOS 10.14.2
Upvotes: 2
Views: 10159
Reputation: 692
Are you sure have python3.7 intalled? you can view the folder
cd /usr/bin
Next you search the python's file:
find /usr/bin/ python3
if don´t exist filename python3.7 install
sudo apt install python3.7
sudo apt update
Upvotes: 1
Reputation: 1593
Your OS uses the PATH environment variable to look for the commands you write into the shell, so if you type python3
it will go through the directories listed in this PATH and check if there's your programm. It takes the first matching program and executes it, so in your case the directory /Library/Frameworks/.../3.6/bin
is before the directory usr/local/bin
, which means that the python3
from /Library/Frameworks/.../3.6/bin
will be used.
You need therefore to change this PATH variable:
export PATH="/Users/sky/Documents/software/Montage-master/bin:/usr/share/file/magic/mercurial:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin"
You can put that into your ~/.bash_profile
so that it is permanent, and you don't need to set it every time you open a new terminal window.
Note that this will not automatically update your path for the remainder of the session. To do this, you should run:
source ~/.bash_profile
Upvotes: 4