Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ImportError: No module named glib

90 views
Skip to first unread message

Michael Joachimiak

unread,
Mar 5, 2010, 3:30:49 AM3/5/10
to pytho...@python.org
I am too new to python.
If anybody has an idea what to do please help.
when I use

import glib

in my code I get this:

>>> import glib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named glib

:~$ python -V
Python 2.6.4

/usr/lib/libpyglib-2.0-python2.6.so.0.0.0 exists in version 2.18.0-0ubuntu2

:~$ pkg-config glib-2.0 --cflags --libs
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0

mblume

unread,
Mar 5, 2010, 5:54:49 AM3/5/10
to
Am Fri, 05 Mar 2010 10:30:49 +0200 schrieb Michael Joachimiak:

> I am too new to python.
> If anybody has an idea what to do please help. when I use
>
> import glib
>
> in my code I get this:
>
>>>> import glib
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named glib
>

Shot in the dark: maybe "import pyglib"?
Hint: you can look around in /usr/lib/python to see what files can be imported.

HTH
Martin

Peter Otten

unread,
Mar 5, 2010, 6:46:54 AM3/5/10
to
Michael Joachimiak wrote:

After the following random walk through my system

$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import glib
>>> glib.__file__
'/usr/lib/pymodules/python2.6/gtk-2.0/glib/__init__.pyc'

In the above __init__.py:
...
from glib._glib import *
_PyGLib_API = _glib._PyGLib_API

del _glib
...

>>> import sys
>>> sys.modules["glib._glib"]
<module 'glib._glib' from
'/usr/lib/pymodules/python2.6/gtk-2.0/glib/_glib.so'>
>>>
$ dpkg -S _glib.so
python-gobject: /usr/lib/pyshared/python2.5/gtk-2.0/glib/_glib.so
python-gobject: /usr/lib/pyshared/python2.6/gtk-2.0/glib/_glib.so
$

... I believe that you have to install the python-gobject package.

Peter

Terry Reedy

unread,
Mar 5, 2010, 12:26:00 PM3/5/10
to pytho...@python.org
On 3/5/2010 3:30 AM, Michael Joachimiak wrote:
> I am too new to python.
> If anybody has an idea what to do please help.
> when I use
>
> import glib
>
> in my code I get this:
>
>>>> import glib
> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> ImportError: No module named glib

glib is not in Python's stdlib so it must be loaded somewhere the
interpreter can find it. Do

>>> import sys
>>> sys.path

and see if it is in any of the listed directories.

Perhaps you need to import pyglib?

Terry Jan Reedy

0 new messages