Search code examples
pythonpython-3.ximporterrorglibtraceback

Error Importing Glib


When trying to import glib in python 3 using from gi.repository import glib, I get an error saying:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2135, in _find_spec
AttributeError: 'DynamicImporter' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 53, in find_module
    'introspection typelib not found' % namespace)
ImportError: cannot import name glib, introspection typelib not found

I installed all the python glib/dev packages using apt-get on Ubuntu 14.04. Attempting to import the module in python 2 says the module doesn't exist.

How do I fix this?


Solution

  • It works for me with GLib correctly capitalized:

    from gi.repository import GLib