I had a working python program that uses GTK3 as installed with homebrew. After updating my OSX system I now get the error:
import gi
File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 42, in <module>
ImportError: cannot import name _gi
The minimal example that produces this error would be:
# import_gi.py
import gi
print gi.__dict__
which produces:
=> /usr/local/Cellar/python\@2/2.7.14_3/bin/python2 import_gi.py
Traceback (most recent call last):
File "import_gi.py", line 1, in <module>
import gi
File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 42, in <module>
ImportError: cannot import name _gi
I've tried running
brew reinstall pygobject3 --with-python2
which did not fix the problem.
Does someone have an idea of what may be going on?
It looks like homebrew is no longer automatically updating python2 by default. This fixed the issue:
brew reinstall pygobject3 --with-python@2