1

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?

krumpelstiltskin
  • 486
  • 7
  • 17

1 Answers1

0

It looks like homebrew is no longer automatically updating python2 by default. This fixed the issue:

brew reinstall pygobject3 --with-python@2
krumpelstiltskin
  • 486
  • 7
  • 17
  • Hi, please help me on this question, thank you. https://stackoverflow.com/questions/54515203/cannot-import-gi-module-python-3-6-on-mac . The command you post here gives me "Error: invalid option: --with-python@2" – Cindy Feb 04 '19 at 14:03