Using MacPorts Python packages in different Python

Ned Deily nad at acm.org
Tue Apr 17 11:25:11 PDT 2012


In article <71147BAB-DD71-4110-91D9-E7BB113708A9 at fusion.gat.com>,
 Sterling Smith <smithsp at fusion.gat.com> wrote:
> I do not use the Enthought python distribution, but in other python 
> distributions the path that is searched for modules is affected by the 
> PYTHONPATH environment variable, and is also accessible/editable in the 
> python interpreter by 
> 
> import sys
> sys.path.append('/path/to/add/')

Something like that would likely work for pure Python modules.  The 
sticky problem is with C extension modules.  To be able to reliably 
share them between Python instances, you need to ensure that the two 
Pythons were configured and built compatibly, i.e. same arch selections, 
compatible ABIs (deployment target settings), same internal Unicode 
settings (UCS-2 vs UCS-4), etc.  Without auditing the code in the 
extension module, it's nearly impossible to know ahead of time whether 
there will be problems are not.  An extension module might not be 
importable without an exception (good) but (bad) it might work for days 
until you hit some other path in your code.  Most people decide it's not 
worth the risk.  If you need to use more than one Python instance, 
install everything you need in each of them.

-- 
 Ned Deily,
 nad at acm.org



More information about the macports-users mailing list