This isn't a really happy combination, but it does work for the most of the time. However, I just bumped into a problem with Gio.File. This will always result in TypeError and Python segfaulting:

Python 2.7.3 (default, Apr 10 2012, 12:29:04) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import GObject, Gio
>>> import gst
>>> la = Gio.File.new_for_path("/home/dklasinc/foo")

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
ERROR:/build/buildd/pygobject-3.2.0/gi/_gobject/pygobject.c:929:pygobject_new_full: assertion failed: (tp != NULL)

Is there a way around this? I'd like to use Gio for file copy operations so that I can provide users with some feedback.


What version of Ubuntu are you on? At this point, you actually shouldn't be able to use PyGI with any of the old static pygobject stuff. If this was working, it was pretty much by accident. On Precise anyway, if the order of the imports is reversed, you get an exception explaining the issue:

>>> import gst
>>> from gi.repository import GObject, Gio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 23, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

As a work around, can you have your UI call a helper script, and in that script only use the static gst/gobject stuff?

Although very bleeding edge still, GStreamer 1.0 completely supports PyGI. There are packages in Quantal, and backports are available for Precise. See my GStreamer 1.0 Python Porting Guide.

  • I sometimes get segfaults when I try mixing introspected and static libraries. It's a can of worms – Manish Sinha Apr 26 '12 at 13:40
  • Well, I sort of new what I was getting into. I wanted Kazam to be Gtk3 app and mostly Python3 ready and I knew I'll have to wait for GStreamer 1.0, unfortunately it didn't land in 12.04. :/ – BigWhale Apr 27 '12 at 8:06

You can't combine Gobject introspection and the static GStreamer bindings, it causes crashes and problems. You need to use introspection for GStreamer too, and this is really only supported with the 0.11/1.0 releases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.