Search code examples
pythonbashmacosmacports

Mac OS X 10.10 MacPorts Python select


I installed Python 2.7 on my Mac with MacPorts (https://www.macports.org/).

After the installation I set the $PATH variable to include the MacPorts directory which worked fine:

$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Then I set the version I want to use with the python-selector:

$ sudo port select --set python python27

from this list:

$ sudo port select --list python
Password:
Available versions for python:
    none
    python26-apple
    python27 (active)
    python27-apple
    python34

Now to test, if everything worked fine I do this and get the strange result:

$ which python
python is /opt/local/bin/python
python is /usr/bin/python

So now I am not sure what's going on. Python terminal uses the right version and everything seems to be working so far. But I was expecting only one python version as active. Is this bad? Is there anything I can or must do?


Solution

  • I'm not sure where your which comes from (check with which which) and whether you implicitly pass any flags to which (check with type which), but that's the output I'd expect if you called which -a python.

    Btw, if you're trying to find out what your shell is going to do when you type python, you should use type python, which is a shell built-in. It has the advantage of using the shell's cache (so it won't show you /opt/local/bin/python while typing python still gives you /usr/bin/python because you have not run hash -r or opened a new shell) and takes shell aliases and functions into account.

    Long story short: Looks fine the way it is.