ImportError: cannot import name GObject, introspection typelib not found

Hi, I was trying to create a simple snap to import GObject from python3-gi. I have tried import every library that it requires. But it never seems to work and return “ImportError: cannot import name GObject, introspection typelib not found”.

But when I run it without the snap it work perfectly fine.

Here is my snapcraft.yaml file.

I have been stuck with this problem for a while now.

Please help.

Thanks in advance

name: hello
version: '1.0'
summary: Basic snapd-control consumer snap
description: A basic snap declaring a plug on snapd-control

grade: devel
confinement: strict
base: core20

    source: hello
    plugin: python
      - python3
      - python3-gi
      - python3-gi-cairo
      - gir1.2-gtk-3.0
      - gobject-introspection
      - libgirepository1.0-dev
      - gir1.2-glib-2.0
      - python3-configobj

    command: bin/hello
    plugs: [network, network-bind]
      PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$PYTHONPATH

I actually found the solution for this.

In the snap -apps:

You will have to include: this line in the environment:

   GI_TYPELIB_PATH: $SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0

Then it works

1 Like