Search code examples
pythonpathmacports

How to locate MacPorts Python on my system?


The core question is: How can I find those pythons which were installed by MacPorts?

A bit more more information:

I installed a port from MacPorts which had both, python37 and python38, as dependencies. I am now trying to find out where these distributions are installed, since I need to call respective scripts with those pythons. They wouldn't run if I use a different one which has already been on my system.

I found /opt/local/bin/python3.8, which I think was not there before. I am not sure though. This folder however does not contain a python3.7 as well.

My system has other distributions on it as well. Those which came with MacOS, and the one which came with Anaconda. I know where I can find the anaconda distribution, and I think the MacOS ones are in /usr/bin/, but I am also not 100% sure if all of those located there came with the OS, or if they may also contain the ones which were ported from MacPorts.

Thanks for help!


Solution

  • I would post a comment if I could (low reputation)...

    Since I'm going through a similar situation at the moment, I thought about a few things that could help you (which can be obvious, but then again, posting them as a comment could be more appropriate.)

    Yes, everything MacPorts-related is installed at /opt/local, usually. You can search there for any Python version. Some other points:

    • Perhaps since you already had Python 3.7 installed somewhere MacPorts didn't install it anew
    • Take a look at your $PATH environment variable. It will give you an idea of what's being searched for first.
    • You can always run something like sudo find / -type f -name "python*" to try and find anything Python-related (you don't strictly need sudo but it helps avoiding some annoying error messages). This way you will know which Python versions are installed where and by which distribution.

    Oh, perhaps this can help too: port installed would show you everything MacPorts has installed. From here: See what has been installed via MacPorts