22

I would like to change my 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 it's "pointing" to. Now if I type python3.1 it loads the version I want to use, although the PATH is still pointing to 2.6.1. Downloaded along with the Python 3.1 package comes an Update Shell Profile.command - when I run it and then run nano ~/.bash_profile it says:

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 giving me instructions how to?

1
  • For posterity, if you need to check what PATH your shell is using, you can type echo $PATH in the terminal. Commented Oct 12, 2021 at 18:29

4 Answers 4

32
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.

Sign up to request clarification or add additional context in comments.

2 Comments

There is no mention of Python for me in /Library/Frameworks/ now in 2019 having installed python from python.org. It was here for me /usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7 thanks to this answer here: stackoverflow.com/a/2741579/1762493
I needed to also add a symlink by running ... sudo ln -s -f /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /usr/local/bin/python
3

try the below lines

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

Then restart terminal

Comments

1

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/

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.