Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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']
share|improve this question
    
Not that no-one can help you, but I belive that Python 2.7.4 and 13.04 are in beta. –  nerof61 Apr 10 '13 at 10:45
    
Yes, I know that final 13.04 will be released on April 25. Although I thought the new 2.7 python package was stable (as it's already available from python.org since April 6). –  3k- Apr 10 '13 at 10:50
    
Well, it does say 'Please test'. But it doesn't really matter. It shouldn't make a difference. –  nerof61 Apr 10 '13 at 11:11
    
I can import gobject - so definitely not a bug as of now. I would suggest to update the system using sudo apt-get update && sudo apt-get dist-upgrade. That might solve the problem if there was a bug earlier. –  Aditya Apr 10 '13 at 12:22
    
Yes, I suspect my python install is corrupted in some way. Let's see if dist-upgrades works, thanks. –  3k- Apr 10 '13 at 12:32
add comment

3 Answers 3

I may be completely wrong, but I've got a hunch you should use from gi.repository import GObject

share|improve this answer
    
Only if you want to use the new gobject-introspection dynamic bindings. For the (old) static bindings, the import from the question should be fine. –  Timo Apr 10 '13 at 11:13
    
@Timo Ah, Ok guessing I should delete this then. –  handuel Apr 10 '13 at 11:15
add comment

The old static bindings for GObject are located in the python-gobject-2 package.

The following path should exist: /usr/lib/python2.7/dist-packages/gobject/

share|improve this answer
    
Thanks for the tip. The package is already the newest version and the mentioned path does exist, however I still cannot import the module. I'm beginning to think my python installation is messed up somehow... –  3k- Apr 10 '13 at 11:31
add comment

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.

share|improve this answer
    
Ah yes, manually installing Python was a great tip if you've put that in your question :-). It's not an unfriendly location, /usr/local is correct. It's just that the Ubuntu packages get installed in /usr and thus can't be found by your own installed Python. Why would you install it manually anyway if the same version is in the repositories? –  Timo Apr 10 '13 at 13:59
    
Because I was using Quantal and the package I've found was for Raring, so for first I tried to compile it myself before having to upgrade to Raring. I simply wasn't aware that I can upgrade the distro before the official release. –  3k- Apr 10 '13 at 14:10
    
I've changed the title and the tags of the question according to the final answer. :) Thanks! –  3k- Apr 10 '13 at 14:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.