I use MacPorts to install Python and any third-party modules tracked by MacPorts into /opt/local
, and I install any manually installed modules (those not in the MacPorts repository) into /usr/local
, and this has never caused any problems. I think you may be confused as to the use of certain MacPorts scripts and environment variables.
MacPorts python_select
is used to select the "current" version of Python, but it has nothing to do with modules. This allows you to, e.g., install both Python 2.5 and Python 2.6 using MacPorts, and switch between installs.
The $PATH
environment variables does not affect what Python modules are loaded. $PYTHONPATH
is what you are looking for. $PYTHONPATH
should point to directories containing Python modules you want to load. In my case, my $PYTHONPATH
variable contains /usr/local/lib/python26/site-packages
. If you use MacPorts' Python, it sets up the other proper directories for you, so you only need to add additional paths to $PYTHONPATH
. But again, $PATH
isn't used at all when Python searches for modules you have installed.
$PATH
is used to find executables, so if you install MacPorts' Python, make sure /opt/local/bin
is in your $PATH
.