You are not logged in.

#1 2013-02-07 03:50:30

TheEdwardRCT
Member
Registered: 2012-12-17
Posts: 26

[SOLVED] Python, PyGTK and Cairo

Hi, good evening.
My issue here is that every application that uses Python and GTK does not start, i get this error

Traceback (most recent call last):
  File "sozi.py", line 31, in <module>
    from sozi.ui import *
  File "/usr/share/inkscape/extensions/sozi/ui.py", line 19, in <module>
    import gtk, gtk.glade
  File "/usr/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
    from gtk import _gtk
ImportError: No module named cairo

That's with sozi, but with Bleachbit i have the same issue, but it says "gobject" instead of "cairo".
The problem is also with Bleachbit-Cli installed form the AUR. I've searched before on the forums and i don't seem to find any solution to this problem. Do you know any way of having this working? I have many Python apps and i really need them.
Thanks!
EDIT: I forgot a little detail, i've also reinstalled the packages python2, python2-cairo, python2-gobject and pygtk. Many, many times. Also, when i do in the terminal "python2", and then i try to load the module gtk, it says that "module doesn't have atributte CAPI", with "import cairo" there is no problem, so it seems it is with PyGTk...


UPDATE: Trying to reinstall python2-cairo pacman told me that the directory /usr/lib/python2.7/site-packages/cairo had different permissions, it should be 755 and it was 700. So now my problem is solved, thank you for your help.

Last edited by TheEdwardRCT (2013-02-07 22:13:40)

Offline

#2 2013-02-07 09:13:14

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: [SOLVED] Python, PyGTK and Cairo

I don't know if this is your problem, but from what I see, 'pygtk' needs 'python2-gobject2' not 'python2-gobject'.
Install it and see if it resolves the issue with 'sozi' and 'bleachbit' which both depend on 'pygtk'.

Offline

#3 2013-02-07 11:57:35

TheEdwardRCT
Member
Registered: 2012-12-17
Posts: 26

Re: [SOLVED] Python, PyGTK and Cairo

I have both python2-gobject and python2-gobject2 installed, i've tried to reinstall both and also reinstaled PyGTK, the problem is still there:/ I will put the output of trying to import module GTK and then cairo

python2
Python 2.7.3 (default, Dec 22 2012, 21:27:36) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
    from gtk import _gtk
ImportError: No module named cairo
>>> import cairo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cairo
>>> print cairo

Offline

#4 2013-02-07 13:29:28

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] Python, PyGTK and Cairo

Does this help?

>>> import cairo
>>> cairo.__file__
'/usr/lib/python2.7/site-packages/cairo/__init__.pyc'

$ pacman -Qo '/usr/lib/python2.7/site-packages/cairo/__init__.pyc'
/usr/lib/python2.7/site-packages/cairo/__init__.pyc is owned by python2-cairo 1.10.0-1

Offline

#5 2013-02-07 19:53:42

TheEdwardRCT
Member
Registered: 2012-12-17
Posts: 26

Re: [SOLVED] Python, PyGTK and Cairo

i get this

 Today is 13-02-07, time 13:51
 The root, detected at the-sun in /home/earth
 Yes, Master root? > # 
pacman -Qo '/usr/lib/python2.7/site-packages/cairo/__init__.pyc'
error: No package owns /usr/lib/python2.7/site-packages/cairo/__init__.pyc

and also this

>>> import cairo
>>> cairo.__file__
'/usr/lib/python2.7/site-packages/cairo/__init__.pyc'

Offline

#6 2013-02-07 21:38:56

TheEdwardRCT
Member
Registered: 2012-12-17
Posts: 26

Re: [SOLVED] Python, PyGTK and Cairo

I've just tried this, when i load the module cairo before the gtk module, this is what i get

>>> import cairo
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
    from gtk import _gtk
AttributeError: 'module' object has no attribute 'CAPI'
>>> 

I don't know anything about that CAPI attribute, but also, i see that everything i do under the command 'python2', even in root, it is not saved, so, how do i do this? Or loading the cairo module before the gtk one doesn't do anything? Thanks.!
EDIT: I've also tried changing from '#!/usr/bin/env python' to ' #!/usr/bin/env python2' because in the official page of Sozi it says that it need Python2 and also recommended by the arch wiki. Still having the same issue. Also, with Bleachbit i get the same. It says that 'cairo' module does not exist, but i have python2-cairo installed.

Last edited by TheEdwardRCT (2013-02-07 22:08:53)

Offline

#7 2013-02-07 22:31:30

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: [SOLVED] Python, PyGTK and Cairo

Here I have not 'pygtk' and I don't get any error with 'import gtk' or 'import cairo' from the python2 prompt.

So try to uninstall 'pygtk' and see if you still have the same error with the 'import gtk' command in python2.

If you don't see the error anymore,
and you get it again when re-installing 'pygtk',
and you are sure that you have only the Arch python2 packages installed, without anything special,
I think you can try to open a bug on 'pygtk'.

I don't want to install it just for testing here.

Edit: I see from your 23:13:40 update that you solved that issue, so my post is useless, but it's good you found the cause now.

Last edited by berbae (2013-02-07 22:40:55)

Offline

Board footer

Powered by FluxBB