0

So I have 2 versions of python on my mac: 2.7.5 , 2.7.8

When I type python in my terminal the 2.7.5 interpreter opens up and when I do /opt/local/bin/python2.7 in my terminal 2.7.8 interpreter opens up.

How do I make it so that when I type python in terminal the 2.7.8 version opens up? Also when I run/compile a python code by typing python test.py it should be done using 2.7.8 ?

PS :- I didn't realise until recently that I had 2.7.8 on my macbook. I have installed a lot of modules using easy_install and was wondering if all of these will work with 2.7.8 version too?

UPDATE:

i found out that macs use .profile instead of bash_profile. When I open up my .profile file, I see the following :

# MacPorts Installer addition on 2014-03-04_at_12:15:52: adding an appropriate $
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

**Update 2 : **

I have tried all solutions listed here : How to: Macports select python

and none work for me

Community
  • 1
  • 1
sukhvir
  • 5,265
  • 6
  • 41
  • 43

1 Answers1

1

Open the file .bash_profile from your home directory in your favorite editor. If it doesn't exist, create it.

In this file, type this line:

export PATH="$HOME/bin:/opt/local/bin:$PATH"

Save this file.

Next, create your own bin directory, with this command:

mkdir -p $HOME/bin

Next, create a symbolic link in this directory:

ln -s /opt/local/bin/python2.7 $HOME/bin/python

Close your terminal and open it again.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284