GStreamer Python compiled from source

Hello, I compiled GStreamer 1.24.12 with Python binding support for Raspberry Pi 4. I can’t get a basic Python GStreamer script running - I get error ValueError: Namespace Gst not available. I do set the following environment variables:

LD_LIBRARY_PATH=/userdata/gstreamer/lib:/userdata/gstreamer/lib/aarch64-linux-gnu
PYTHONPATH=/userdata/gstreamer/lib/python3/dist-packages:/userdata/gstreamer/lib/python3/dist-packages/g

What could I be missing? Thanks a bunch!

Full error:

python3 gst-test.py
Traceback (most recent call last):
  File "/workspace/gst-test.py", line 2, in <module>
    gi.require_version('Gst', '1.0')
  File "/userdata/gstreamer/lib/python3/dist-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available

I think you also need gobject introspection. I have added that to other platforms, but not RPi.

Any tips for adding or trying that myself? Here is my full build command it does include -Dintrospection=enabled:

time meson setup --reconfigure build_dir --prefix=/userdata/chirp/gstreamer --buildtype=release -Dpython=enabled -Dintrospection=enabled -Dgstreamer:gst_debug=true -Dgst-plugins-bad:webrtc=enabled -Dgpl=enabled -Dgst-plugins-bad:webrtcdsp=enabled -Dgst-plugins-good:lame=disabled -Dgst-plugins-good:twolame=disabled -Dgstreamer:coretracers=disabled -Dpackage-origin=https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.24.12.tar.xz

Thank you!

You should just need to sudo apt-get install gobject-introspection

There is a similar problem here.

I believe I have gobject-introspection installed:

root@WATER:/# apt-get install gobject-introspection
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gobject-introspection is already the newest version (1.66.1-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

also, I’m building on RPI4 but in docker container, here is my docker image info:

root@WATER:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

I’ve zipped up the output of all the built gstreamer files copied to a location via install command, anything obvious missing there perhaps the introspection files?

https://drive.google.com/file/d/1ecStt0YN0Myl4wYSCTx_Paa7qY850vA3/view?usp=drive_link

Thanks a bunch

So you are building gstreamer in a container, then installing it in the base system, and running the Python script in the base system?

If that is true, I think you need to install gobject-introspection in the base system, so that the Python gi module can use it. It looks like you were installing it in the container.

That’s the idea, though the above error was from running within the container which has gobject-introspection installed.

I tried running outside the container and after installing gobject-introspection. I still get some error:

pi@WATER:~/workspace/ $ LD_LIBRARY_PATH=/gstreamer/lib:/gstreamer/lib/aarch64-linux-gnu PYTHONPATH=/gstreamer/lib/python3/dist-packages:/gstreamer/lib/python3/dist-packages/gi python3 gst-test.py
Traceback (most recent call last):
  File "/home/pi/workspace/gst-test.py", line 1, in <module>
    import gi
  File "/gstreamer/lib/python3/dist-packages/gi/__init__.py", line 22, in <module>
    from pkgutil import extend_path
  File "/usr/lib/python3.11/pkgutil.py", line 4, in <module>
    from functools import singledispatch as simplegeneric
  File "/usr/lib/python3.11/functools.py", line 22, in <module>
    from types import GenericAlias
  File "/gstreamer/lib/python3/dist-packages/gi/types.py", line 23, in <module>
    import re
  File "/usr/lib/python3.11/re/__init__.py", line 124, in <module>
    import enum
  File "/usr/lib/python3.11/enum.py", line 3, in <module>
    from types import MappingProxyType, DynamicClassAttribute
ImportError: cannot import name 'MappingProxyType' from partially initialized module 'types' (most likely due to a circular import) (/gstreamer/lib/python3/dist-packages/gi/types.py)