Ubuntu – Python: module not found after manual install

compilingconfigurationpackage-managementpythonsoftware installation

I've recently updated to the current version of Ubuntu, 13.04 and Python 2.7.4. Since then I have problems importing the gobject module and dunno what to do to fix it. I'd like to use dreampie which currently fails at startup with the ImportError below. Here are more details:

kiri:/home/kiri% uname -a
Linux megfigyelokocsi-2 3.8.0-17-generic #27-Ubuntu SMP Sun Apr 7 19:39:35 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
kiri:/home/kiri% sudo apt-get install python-gtk2 python-gobject python-gobject-2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-gobject-2 is already the newest version.
python-gobject is already the newest version.
python-gtk2 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
kiri:/home/kiri% python
Python 2.7.4 (default, Apr  9 2013, 19:58:39) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gobject
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named gobject

I also did try to install dreampie from source before:

git clone git://github.com/noamraph/dreampie.git dreampie
cd dreampie
sudo python setup.py install

Installation succeeded but it didn't help. How can I make python recognize the gobject module?

EDIT: The module does exist at the following path, but importing still does not work:

/usr/lib/python2.7/dist-packages/gobject/

EDIT2: I already tried to fix my assumably corrupt python installation (w/o success):

sudo zsh
apt-get remove --purge python2.7-minimal
apt-get remove --purge python2.7
apt-get autoremove
apt-get install python2.7-minimal
apt-get install python2.7

also tried to upgrade my distribution, but it says everything's up-to-date:

sudo zsh
apt-get clean && apt-get update
apt-get dist-upgrade
apt-get upgrade

EDIT 3: sys.path:

kiri:/home/kiri% python -c "import sys; print sys.path"    
['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7',      
'/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages']

Best Answer

After inspecting sys.path I've realized that the interpreter was loaded from a wrong location (/usr/local/bin instead of /usr/bin/), so I did:

sudo rm -rf /usr/local/bin/python*

And now it works! Earlier I tried to build & install python from the source tarball (with success) and it seems it put its binaries to an Ubuntu-unfriendly location. The problem was rooted in the fact that /usr/local/bin precedes /usr/bin in the PATH variable.