python parser overridden by pymol

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Nov 11 22:16:32 EST 2009


On Wed, 11 Nov 2009 17:41:07 -0800, Jeremiah wrote:

> Hello,
> 
> I'm fairly new to python (version 2.5.4), and am writing a program which
> uses both pymol (version 1.2r1) and numpy (version 1.3.0) from debian.
> 
> It appears that when I add pymol to $PYTHONPATH, that parser.expr() is
> no longer available, and so I am unable to use numpy.load(). I have
> looked for where parser.expr() is defined in the python system so I
> could place that directory first in $PYTHONPATH, but I have not been
> able to find the file that defines expr().


>>> import parser
>>> parser.__file__
'/usr/lib/python2.5/lib-dynload/parsermodule.so'
>>> parser.expr
<built-in function expr>



[...]
> However, a problem arises once $PYTHONPATH includes the pymol
> directory. To use the pymol api, I add the following to ~/.bashrc:
> 
>    PYMOL_PATH=/usr/lib/pymodules/python2.5/pymol
>    export PYMOL_PATH
>    PYTHONPATH=$PYMOL_PATH
>    export PYTHONPATH


Change that to 

    PYMOL_PATH=/usr/lib/pymodules/python2.5


and it should work, assuming pymol uses a package, as it should. If it 
doesn't, if it's just a hodge-podge of loose modules in a directory, then 
they should be slapped with a wet fish for shadowing a standard library 
module.



-- 
Steven



More information about the Python-list mailing list