Macports: switching back to the system default version of Python

bashmacportspythonterminal

I'm trying to use Macports to switch back to the system default version of python.

When I run this command:

port select --list python

I get back :

Available versions for python:
    none
    python26-apple
    python27
    python27-apple (active)
    python34

So for example, I want to switch back to the usr/bin/python (which is the apple version of python), I would enter this into the terminal:

 sudo port select --set python python26-apple

It says:

Selecting 'python26-apple' for 'python' succeeded. 'python26-apple' is
now active.

But, when I run which python, it gives me this:

/opt/local/bin/python

Which is not the system default version of python. That is the Macports version of python as Macports installs all their python versions into the /opt/local/bin directory.

I want to type in which python and get back this when I switch to the apple version of python:

/usr/bin/python

When I type into Terminal type -a python, I get back these two versions of pythons installed on my mac. The first one is where all the Macports versions of python get installed. The second one is the system version of Python:

python is /opt/local/bin/python
python is /usr/bin/python

I have read this post: How do I change back from MacPorts Python to system default version? however, it doesn't seem to address this problem.

Best Answer

/opt/local/bin/python is a symbolic link to the active version of python. You can view the structure with the following command:

ls -l /opt/local/bin/python*

Since /opt/local/bin is before /usr/bin in your PATH variable then the symbolic link will be listed first but it points to the version in /usr/bin.