[Tutor] Re: module search path order (was: gettext mystery)

Michael Lange klappnase at freenet.de
Sun Nov 7 21:20:14 CET 2004


On Fri, 05 Nov 2004 18:44:47 -0500
Kent Johnson <kent_johnson at skillsoft.com> wrote:

Kent, thanks for the reply,

> I don't know why you get a different gettext depending on when you import 
> it...maybe something is being added to sys.path?

There's nothing added to sys.path, it's the order which is different;
if I add a " print sys.path " to /usr/bin/moleskine I get:

['/usr/bin', '/usr/lib/python2.2', '/usr/lib/python2.2/plat-linux-i386', '/usr/lib/python2.2/lib-tk', '/usr/lib/python2.2/lib-dynload', '/usr/lib/python2.2/site-packages', '/usr/lib/python2.2/site-packages/Numeric', '/usr/lib/python2.2/site-packages/PIL', '/usr/lib/python2.2/site-packages/gtk-1.2']

if I add it to /usr/lib/python2.2/site-packages/Moleskine/MoleskineApp.py I get:

['/usr/bin', '/usr/lib/python2.2/site-packages/gtk-1.2', '/usr/bin', '/usr/lib/python2.2', '/usr/lib/python2.2/plat-linux-i386', '/usr/lib/python2.2/lib-tk', '/usr/lib/python2.2/lib-dynload', '/usr/lib/python2.2/site-packages', '/usr/lib/python2.2/site-packages/Numeric', '/usr/lib/python2.2/site-packages/PIL']

I guess that's the reason why MoleskineApp.py imports the gettext module from the site-packages/gtk-1.2 directory .

> You might be able to get it to work by deleting the gtk-1.2/gettext.py so 
> all imports find the standard version. If the newer one is backwards 
> compatible I think this will work.
> 
Unfortunately the two gettext modules aren't compatible, so deleting the one from pygnome is probably no
good idea; anyway, for my current problem doing a sys.path.sort() before importing gettext did the job
just fine, I was just wondering if there is a proper way to change the order of the module search path
to force the import of the standard library's module in cases like this.

Best regards

Michael



More information about the Tutor mailing list