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 353808 - import gst throws an exception when imported after gtk
import gst throws an exception when imported after gtk
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
Johan (not receiving bugmail) Dahlin
Depends on:
Blocks:
 
 
Reported: 2006-09-01 10:21 UTC by chris procter
Modified: 2006-09-22 14:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
output from the test script (4.04 KB, text/plain)
2006-09-06 07:46 UTC, chris procter
Details

Description chris procter 2006-09-01 10:21:33 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):
  • File "/home/chris/jokosher/trunk/Jokosher/JokosherApp.py", line 12 in ?
    import gst
  • File "/sources/gstreamer/head/gst-python/gst/__init__.py", line 108 in ?
    from _gst import *
ImportError: No module named _gst


Expected results:
it to work :) (it to import gst correcty regardless of import gtk position)

Does this happen every time?
yes

Other information:
Comment 1 chris procter 2006-09-01 10:46:11 UTC
This bug brought to you by the Jokosher team
Comment 2 Edward Hervey 2006-09-05 12:54:00 UTC
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 ?
Comment 3 chris procter 2006-09-05 16:51:25 UTC
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 :)

Comment 4 Edward Hervey 2006-09-05 17:06:59 UTC
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
Comment 5 chris procter 2006-09-06 07:46:51 UTC
Created attachment 72295 [details]
output from the  test script
Comment 6 chris procter 2006-09-06 07:49:50 UTC
I added some 
print "==============="
lines to the script to make the output more readable, it also wrote:
Traceback (most recent call last):
  • File "dumpenv.py", line 11 in ?
    import gst
  • File "/sources/gstreamer/head/gst-python/gst/__init__.py", line 108 in ?
    from _gst import *
ImportError: No module named _gst

to stderr.
Comment 7 René Stadler 2006-09-08 01:56:31 UTC
(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.
Comment 8 chris procter 2006-09-08 15:11:23 UTC
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. 

Comment 9 René Stadler 2006-09-08 16:52:58 UTC
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.
Comment 10 Edward Hervey 2006-09-22 11:58:14 UTC
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.
Comment 11 chris procter 2006-09-22 13:25:02 UTC
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.