GNOME Bugzilla – Bug 353808
import gst throws an exception when imported after gtk
Last modified: 2006-09-22 14:33:28 UTC
Please describe the problem: if you import gst after you import gtk an exception is thrown Steps to reproduce: 1. get cvs gst-python 2. Create testscript.py containing: import gtk import gst print "hello world" 3. run it with python testscript.py 3. cry Actual results: Traceback (most recent call last):
+ Trace 71350
import gst
from _gst import *
Expected results: it to work :) (it to import gst correcty regardless of import gtk position) Does this happen every time? yes Other information:
This bug brought to you by the Jokosher team
this might seem stupid but ... did you compile you gst-python cvs ? _gst is a binary module which needs to be compiled. Are you running all of this uninstalled ?
I've done enough tech support to know its a very sensible question :) I have gone back and run the following: ~/bin/gst-head cd /sources/gstreamer/head/gst-python autogen.sh make python test.py and I get the same error message, so yes I have compiled it, and yes I'm running uninstalled, but when I mv gst-python to gst-python-broken (so it uses the installed package again) it works as expected so it is picking up the directory. Also if you import gst before gtk then it works so I suspect gst is compiled correctly. ls gst-python/gst/_gst* shows: _gst.la _gst_la-gst-argtypes.lo _gst_la-gst.lo _gst_la-gstmodule.lo _gst_la-pygstexception.lo _gst_la-pygstiterator.lo _gst_la-pygstminiobject.lo _gst_la-pygstvalue.lo I'm using Edgy on ppc with python-gtk2 version 2.10.1-0ubuntu1 (it also occured with 2.9.6-0ubuntu2 before I dist-upgrade'd) If you import gst first then gtk if works, if you import gtk then gst the error descibed occurs I also have Dapper on the same machine with python-gtk2 version 2.8.6-0ubuntu1 and that works correctly so its my fault for using Edgy :)
could you run the following testfile: import sys print "path", sys.path import gtk print "path", sys.path print "modules", sys.modules print gtk import gst
Created attachment 72295 [details] output from the test script
I added some print "===============" lines to the script to make the output more readable, it also wrote: Traceback (most recent call last):
+ Trace 71710
to stderr.
(In reply to comment #0) [...] > Steps to reproduce: > 1. get cvs gst-python > 2. Create testscript.py containing: > import gtk > import gst > print "hello world" > [...] I cannot reproduce this, but I can say that this program is a bit too minimalistic. You have to do something like: import pygtk pygtk.require ("2.0") import gtk import pygst pygst.require ("0.10") import gst This ensures that the correct bindings are selected if your system has multiple versions available (on my system, "import gst" happily imports 0.8 bindings otherwise). To do so, IIRC it does some messing with the module search path, so I suspect this to be the source of your problem.
That was just the most minimalistic program I could come up with that would cause the bug, sadly the test program:- import pygtk pygtk.require ("2.0") import gtk import pygst pygst.require ("0.10") import gst print "hello world" has exactly the same problem, as does starting Jokosher.
Your problem might be related to ltihooks. It does work OK if you "make install" to some location and use if from there, right? Your module search path has "/sources/gstreamer/head/gst-python" pretty much at the beginning. Like Edward, I assume you try to run against the uninstalled pygst in its build (== src) directory. This is how the tests are supposed to be run, for example. When the module gst._gst is searched for, the file _gst.so cannot be found out of the box as it resides in gst-python/gst/.libs. In gst-python/gst, only the libtool archive _gst.la is to be found. ltihooks.py (in the toplevel directory) makes it possible to transparently redirect the import of gst._gst from the .la to the .so in the .libs subdirectory. This mechanism is somehow broken in you environment. Try to run "make check" and see if the tests work.
Chris, if the make check works for you, I'm going to mark this bug as closed, since it seems to be an issue on your side only.
ok progress: make check blows up completly in a 10 layer traceback :( but having read Rene's comments I noticed I had ltihooks.py in gst-python/ but not in gst-hooks/gst/ so: cp gst-hooks/ltihooks.py gst-hooks/gst/ltihooks.py and suddenly my little test script works, as does Jokosher. I dont really understand why this is the solution, or why importing gtk first fixes it but if I'm the only one who suffers from this then I have a workaround and you can mark this as closed. Thanks to both of you for all your help.