GNOME Bugzilla – Bug 318300
gtk.require() finds non-pygtk directories and adds them to the search path
Last modified: 2006-04-02 21:44:34 UTC
Please describe the problem: if a pygtk program is directly located in /usr/lib and there is a /usr/lib/gtk-2.0 directory (part of gtk+-2.x) then the gtk.require() function assumes that this is the location of pygtk modules and appends "/usr/lib/" to sys.path. The pygtk program can't run because gtk, gnome, ... can't be imported because the /usr/lib and not the correct directory (where the pygtk modules can be found) is used Steps to reproduce: 1. just try this little program: #!/usr/bin/env python import sys import pygtk; pygtk.require("2.0") import gnome import gc import gtk 2. make sure you have a /usr/lib/gtk-2.0 directory 3. copy the program to /usr/bin and /usr/lib 4. python /usr/bin/bugtest.py 5. python /usr/lib/bugtest.py Actual results: the program in /usr/lib prints an error because it can't find the pygtk modules: Traceback (most recent call last):
+ Trace 63438
import gnome
and the program in /usr/bin works fine Expected results: that the python search path is correct Does this happen every time? yes Other information: the attached patch adds a sanity check to pygtk.py which solves the problem
Created attachment 53237 [details] [review] patch solves the problem by adding a sanity check
Hi, please can anybody have a look at this bug report? It is a little bit frustrating for us contributers, if we report bugs, search for a solution, send a patch and got really no reaction from the developers. Thank you very much in advance, Christian
Hello, I'd like to second Christian. This bug is rather annoying if some application installs itself in /usr/local/lib/python2.[34]/site-packages/gtk-2.0 while pygtk is actually installed under /usr/lib/.../gtk-2.0. The /usr/lib/... path is removed from sys.path and further pygtk-modules can't be loaded. Greetings, Matthias
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of 310563 ***