3

Hi I have a Mac and happen to have many different flavors of Python installed everywhere.

right now when I opened up python in terminal, type in

which python

the return result is:

//anaconda/bin/python

I am wondering what should I do to change the default python to a python that I like, so next time when I do:

which python

the path should be:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

Thanks!

1
  • Add an alias to .bash_profile file. Commented Aug 30, 2013 at 17:36

3 Answers 3

2

When you installed Anaconda it should have added a new item to your PATH variable, right at the front. You should see something like this in your *~/.bash_profile* file:

# added by Anaconda 1.8.0 installer
export PATH="//anaconda/bin:$PATH"

You can remove these lines, reopen any terminal window you have and your default Python should have been restored.

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

Comments

1

which command uses the directories listed in $PATH to search for the first occurrence of a command. If you want to list all instances of executables, use -a option.

which python2.7

Output:

/usr/bin/python2.7

This will display symbolic link to /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

to resolve symbolic link use

readlink $(which python2.7)  

output:

../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

2 Comments

when I do which python2.7, I got: //anaconda/bin/python2.7 which is still not what I want.
@ParagBafna when I do 'which python', it still shows the previous path but readlink $(which python2.7) shows the path that I want my python to link to. So does it mean that the path has been updated?
0

Try creating a symbolic link

ln -s /anaconda/bin/python /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

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.