12
votes

I would like to change PATH from Python 2.6.1 to 3.1.2. I have both versions installed on my computer but when I type python --version in the terminal I get Python 2.6.1 so thats the current version its "pointing" to. Now if I type Python3.1 it changes the current version to the one I want to use, though the PATH is still 2.6.1. Downloaded with the Python 3.1 package comes a Update Shell Profile.command, so when I run it and then run nano ~/.bash_profile it says there: Setting PATH for Python 3.1 the orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}" export PATH.

Does this mean that I have changed the PATH or does it just give me instructions how to?!

Regards

4
@Mark, I have always tried to do that when I have felt that I was helped. It is not my intention to appear as ungrateful. I will overlook my questions. - Tim

4 Answers

22
votes
PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}" 
export PATH

This will append the Python directory to the path.

If this is part of ~/.bash_profile, this will append the Python path on each startup.

1
votes

For those using a .zsh terminal instead of .bash, you might need to update your PATH using the command:

nano .zsh

Then update your PATH with the export command.

See the link below for more guide:
https://coolestguidesontheplanet.com/how-to-add-to-the-shell-path-in-macos-using-terminal/

0
votes

try the below lines

cd /usr/local/bin
cp python3.7 python

Then restart terminal

0
votes

i managed to fixed mine by removing python2, i don't if it's a good practice