It is currently Sun Jun 30, 2024 11:04 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: ImportError: When using gi.repository .....
PostPosted: Tue Apr 27, 2021 5:42 am  (#1) 
Offline
GimpChat Member

Joined: Apr 14, 2011
Posts: 67
Location: The Netherlands
A question for coders on Linux.
I'm busy rewriting Indexprint for Gimp. As we know python v2.7 and GTK 2 are deprecated and you have to install phyton 2 separately. So I have installed python 2 and GTK+3. According the instructons found here: https://python-gtk-3-tutorial.readthedo ... stall.html. Changed the Indexprint GUI from GTK 2 into GTK+3 with Glade but then the problems begin. I'm using the gi module and found an error. Trying to import gi module in the Python console of Gimp gives me the following:

------------------------------------
GIMP 2.10.24 Python Console
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0]
>>> import gi
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 39, in <module>
raise ImportError(_static_binding_error)
ImportError: When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject". See: https://bugzilla.gnome.org/show_bug.cgi?id=709183
>>>
-------------------------------

But using Python 2.7 in terminal (so not in Gimp) I'm able to import gi without any error.

I have read the the bugzilla, I looked at the __init__.py but I'm still puzzled I donot see a solution.
What should I change?? Any help should be appreciated.

Some system information:
Using LinuX 20.04 (Xubuntu) with GTK2, GTK+3, Python 2.7 and 3.8 installed.

_________________
Happy Gimping !!


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: ImportError: When using gi.repository .....
PostPosted: Fri Apr 30, 2021 12:12 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
moroquendo wrote:
A question for coders on Linux.
I'm busy rewriting Indexprint for Gimp. As we know python v2.7 and GTK 2 are deprecated and you have to install phyton 2 separately. So I have installed python 2 and GTK+3. According the instructons found here: https://python-gtk-3-tutorial.readthedo ... stall.html. Changed the Indexprint GUI from GTK 2 into GTK+3 with Glade but then the problems begin. I'm using the gi module and found an error. Trying to import gi module in the Python console of Gimp gives me the following:

------------------------------------
GIMP 2.10.24 Python Console
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0]
>>> import gi
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 39, in <module>
raise ImportError(_static_binding_error)
ImportError: When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject". See: https://bugzilla.gnome.org/show_bug.cgi?id=709183
>>>
-------------------------------

But using Python 2.7 in terminal (so not in Gimp) I'm able to import gi without any error.

I have read the the bugzilla, I looked at the __init__.py but I'm still puzzled I donot see a solution.
What should I change?? Any help should be appreciated.

Some system information:
Using LinuX 20.04 (Xubuntu) with GTK2, GTK+3, Python 2.7 and 3.8 installed.


It's possibly a clash between GTK2 (as used by Gimp 2.x) and GTK3 (as used by your Python code).

_________________
Image


Top
 Post subject: Re: ImportError: When using gi.repository .....
PostPosted: Fri Apr 30, 2021 2:20 pm  (#3) 
Offline
GimpChat Member

Joined: Apr 14, 2011
Posts: 67
Location: The Netherlands
Thank you Ofnuts I was already thinking about that. I will give it a try in a vm with Gimp + python 2.7 + GTK3

_________________
Happy Gimping !!


Top
 Post subject: Re: ImportError: When using gi.repository .....
PostPosted: Fri Apr 30, 2021 2:26 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
moroquendo wrote:
Thank you Ofnuts I was already thinking about that. I will give it a try in a vm with Gimp + python 2.7 + GTK3


IMHO it's not a problem that you can solve with a VM. It is likely that the Python support in Gimp 2.x includes bits of GTK2 (for instance, to generate the automatic dialogs) and that this clashes with GTK3. You would have to stay with GTK2...

_________________
Image


Top
 Post subject: Re: ImportError: When using gi.repository .....
PostPosted: Fri Apr 30, 2021 2:41 pm  (#5) 
Offline
GimpChat Member

Joined: Apr 14, 2011
Posts: 67
Location: The Netherlands
ofnuts wrote:
moroquendo wrote:
Thank you Ofnuts I was already thinking about that. I will give it a try in a vm with Gimp + python 2.7 + GTK3


IMHO it's not a problem that you can solve with a VM. It is likely that the Python support in Gimp 2.x includes bits of GTK2 (for instance, to generate the automatic dialogs) and that this clashes with GTK3. You would have to stay with GTK2...


I donot hope so. GTK2 is already problematic, Glade 2 is also deprecated.

_________________
Happy Gimping !!


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group