Based on Jeremy W. Sherman's answer
I checked my python version
python --version
Python 3.8.5
and location:
which python
/opt/local/bin/python
and then tried:
sudo port contents python38
which lists 7285 lines:
Port python38 contains:
/Applications/MacPorts/Python 3.8/IDLE.app/Contents/Info.plist
/Applications/MacPorts/Python 3.8/IDLE.app/Contents/MacOS/IDLE
/Applications/MacPorts/Python 3.8/IDLE.app/Contents/MacOS/Python
/Applications/MacPorts/Python 3.8/IDLE.app/Contents/PkgInfo
...
/opt/local/share/man/man1/python3.8.1
combining that with fardjad's answer leads to:
sudo port contents python38 | grep site-packages
with the output:
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/README.txt
since we need the directory modifying the command to:
dirname $(sudo port contents python38 | grep site-packages)
gives the desired directory:
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
so it's possible to end up with the one-liner:
One-Line PYTHONPATH setting in macports:
export PYTHONPATH=$(dirname $(sudo port contents python38 | grep site-packages))
and we can check the result:
echo $PYTHONPATH
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
For reference see how the Eclipse Liclipse python IDE dialog for setting the PATH looks - there are some more directories you might want to include for a fully specified PYTHONPATH.
