After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 318300 - gtk.require() finds non-pygtk directories and adds them to the search path
gtk.require() finds non-pygtk directories and adds them to the search path
Status: RESOLVED DUPLICATE of bug 310563
Product: pygtk
Classification: Bindings
Component: general
2.8.x
Other All
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-10-08 20:37 UTC by Christian Krause
Modified: 2006-04-02 21:44 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
patch solves the problem by adding a sanity check (679 bytes, patch)
2005-10-08 20:38 UTC, Christian Krause
none Details | Review

Description Christian Krause 2005-10-08 20:37:30 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):
  • File "/usr/lib/bugtest.py", line 5 in ?
    import gnome
ImportError: No module named 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
Comment 1 Christian Krause 2005-10-08 20:38:48 UTC
Created attachment 53237 [details] [review]
patch solves the problem by adding a sanity check
Comment 2 Christian Krause 2006-02-25 14:55:03 UTC
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
Comment 3 Matthias Rosenkranz 2006-03-03 08:57:16 UTC
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
Comment 4 Gustavo Carneiro 2006-04-02 21:44:34 UTC
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 ***