Install gtk 3 for python on mac

I installed python gtk3 using homebrew but it prints

Warning: gtk + 3-3.14.6 is already installed

but when i try to import it in python

from gi.repository import Gtk 

he gives an error

ImportError: no module named gi.repository

Please, help.

+8
source share
3 answers

When I installed only pygobject3 , I got the following error when running a Python script:

  gi.require_version('Gtk', '3.0') File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 102, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gtk not available 

So it seems to me that you need to install both packages in order to get gtk3 with python bindings on Mac OS X:

 brew install gtk+3 pygobject3 
+6
source

Python bindings are not provided by GTK +. You need to install pygobject3 .

+3
source

Installation using homebrew worked for me on 10.14:

 brew install pygobject3 --with-python@2 gtk+3 

References:

https://pygobject.readthedocs.io/en/latest/getting_started.html#macosx-logo-macos

+1
source

All Articles