1

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.

2 Answers 2

4

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

0
0

Select none as a variant

sudo port select --set python none

This will remove the link /opt/local/bin/python, therefor /usr/bin/python will be selected instead.

2
  • Yes but that will be python2.7 not the 2.6 the OP wants.
    – mmmmmm
    May 18, 2021 at 16:36
  • @mmmmmm The OP ask how to "switch back to the system default version of python". It was 2.6, now it's 2.7.
    – gagarine
    May 28, 2021 at 9:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .