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.

How can I access the gio module for Python 3.2? (I want to interface with GVFS.) I did

sudo apt-get install python3-gobject

but this does not allow me to do

import gio

as it did in Python 2.7. Is the GIO module not provided with GObject in Python 3? How do I access it?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

gio is a PyGTK module, and is not available for Python 3 because PyGTK itself is deprecated. If you want to create a GTK+ application in Python 3, you will need to use its replacement: PyGObject. In the case of Gio, you import it like this.

$ python3
Python 3.2.2 (default, Sep  5 2011, 21:17:14) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gio

Such documentation as exists can be found here. Best of luck!

share|improve this answer
add comment

It appears to be renamed to 'gi':

$ python3
Python 3.2.2 (default, Sep  5 2011, 22:09:30)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>

See the file listing of the python3-gobject package: http://packages.ubuntu.com/oneiric/i386/python3-gobject/filelist

share|improve this answer
    
This answer is simply wrong. See @Jacob's answer for the correct import. –  Bobble Apr 1 '13 at 14:19
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.