could not find _PyGObject_API object

Hello,

I am using OpenSUSE 12.1 (x86_64) and when I execute a python script that uses PyGTK I receive the error:

ImportError: could not import gobject (could not find _PyGObject_API object)

The script uses matplotlib but I think the error is not specific to that library.
The problem is reproduced by:

python -c "from matplotlib.backends._gtkagg import agg_to_gtk_drawable"

I have both python-gobject and python-gobject2 installed and this page suggests that it might be the cause of the error but I don’t see how can I remove either one if they are both needed by other packages:

net@linux-q4qx:~> zypper info --requires python-gobject
Loading repository data...
Reading installed packages...


Information for package python-gobject:

Repository: openSUSE-12.1-Update
Name: python-gobject
Version: 3.0.2-2.3.1
Arch: x86_64
Vendor: openSUSE
Installed: Yes
Status: up-to-date
Installed Size: 1.3 MiB
Summary: Python bindings for GObject
Description: 
Pygobjects is an extension module for python that gives you access to
GLib's GObjects.
Requires:
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libglib-2.0.so.0()(64bit)
libgobject-2.0.so.0()(64bit)
/usr/bin/env
typelib(GLib)
typelib(GObject)
libgirepository-1.0.so.1()(64bit)
typelib(cairo)
libffi.so.4()(64bit)
libpyglib-gi-2.0-python.so.0()(64bit)
python(abi) == 2.7
python == 2.7


net@linux-q4qx:~> zypper info --requires python-gobject2
Loading repository data...
Reading installed packages...


Information for package python-gobject2:

Repository: openSUSE-12.1-Oss
Name: python-gobject2
Version: 2.28.6-9.1.3
Arch: x86_64
Vendor: openSUSE
Installed: Yes
Status: up-to-date
Installed Size: 1.2 MiB
Summary: Python bindings for GObject
Description: 
Pygobjects is an extension module for python that gives you access to
GLib's GObjects.
Requires:
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
/sbin/ldconfig
libc.so.6(GLIBC_2.14)(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libglib-2.0.so.0()(64bit)
libgobject-2.0.so.0()(64bit)
/usr/bin/env
libgio-2.0.so.0()(64bit)
libgthread-2.0.so.0()(64bit)
libffi.so.4()(64bit)
libpyglib-2.0-python.so.0()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsLzma) <= 4.4.6-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
python(abi) == 2.7
python == 2.7

What can I do to make python (2.7.2) import the gobject successfully?

On 2012-06-16 11:36, someuser77 wrote:
> What can I do to make python (2.7.2) import the gobject successfully?

Perhaps you should ask in the programming forum.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Looks to me that your installation is damaged.
_PyGObject_API is defined in
/usr/lib64/python2.7/site-packages/gobject/_gobject.so
Check that that file exists, it is part of python-gobject2 which is
installed on your system.

Probably do a forced reinstall of python-gobject2 in yast.


PC: oS 12.1 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.4 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10