Re: [gtk-osx-users] ImportError: No module named gi.





On Mar 31, 2019, at 2:03 AM, Pascal <p p14 orange fr> wrote:


Le 31 mars 2019 à 04:53, John Ralls <jralls ceridwen fremont ca us> a écrit :

On Mar 30, 2019, at 10:55 AM, Pascal <p p14 orange fr> wrote:


Le 30 mars 2019 à 03:41, John Ralls <jralls ceridwen fremont ca us> a écrit :

On Mar 29, 2019, at 2:20 PM, Pascal <p p14 orange fr> wrote:

Hello,

I have install GTK+ 3 and Python with:
$ jhbuild build python

Then PyObject with:
$ jhbuild build pygobject

But I've the error: "ImportError: No module named gi"

Where is it wrong?

pygobject needs gobject-introspection. Build meta-gtk-osx-core-gtk3 instead of just gtk+-3.0.
Also you need python3 rather than python nowadays.

Hello John,

Sorry, my wording was incorrect.
$ jhbuild build pygobject
is built without any error.
But I've got "ImportError ... gi" when running my app.

Well, I built python3 and pygobject3 but I've got another error:
$ jhbuild build python3
$ jhbuild build pygobject3
*** Building pygobject3 *** [4/4]
python setup.py build
Traceback (most recent call last):
File "setup.py", line 29, in <module>
 import pkg_resources
ImportError: No module named pkg_resources

Note that it calls python, not python3. Since you have built both (and maybe even if you hadn't) you need 
to link $PREFIX/bin/python3 to $PREFIX/bin/python, replacing the python2 link.

Thanks John for the tip, I should have guess it on my own ;-)

Now "jhbuild build pygobject3" is ok and I get "gi":
/usr/local/xnadalib-2018/lib/python3.6/site-packages/gi
$ jhbuild shell
Prefix: /usr/local/xnadalib-2018
Entered jhbuild shell, type 'exit' to return.
[JH] bld$ python
Python 3.6.4 (default, Mar 30 2019, 18:42:23) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from gi.repository import Gtk
__main__:1: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', 
'3.0') before import to ensure that the right version gets loaded.

But my app seems to expect python 2:
   print 'PYTHON_VERSION=%s' % get_config_var("VERSION")
                           ^
SyntaxError: invalid syntax

Does "gi" exist for python 2? How to get it?

Build pygobject3 with python2. pygobject is for Gtk2.

Python2 goes out of support at the end of *this year*. It's way past time that you covert your app to 
python3. It's not hard, most apps can be converted in a day or two.

Regards,
John Ralls


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]