Cannot import name '_gi'

Thanks to a comment by Wilhelm, I found that the solution is:

sudo ln -s /usr/lib/python3/dist-packages/gi/_gi.cpython-{36m,37m}-x86_64-linux-gnu.so

This worked for me with Python 3.7 on Ubuntu.


This is an old issue, but if someone needs a quick solution , that doesn't imply changing the default Python versions anywhere, just:

sudo python3.6 /usr/bin/apt-add-repository ppa:mosquitto-dev/mosquitto-ppa

These 2 steps may help you

$ cd /usr/lib/python3/dist-packages/gi
$ sudo ln -s _gi.cpython-{36m,37m}-x86_64-linux-gnu.so

Ubuntu does not like to switch its default interpreter away from python 3.7.

So switch it back to 3.6 by using

sudo update-alternatives --config python3

After that try to install the gi package:

sudo apt install python3-gi

Tags:

Python

Pi

Ubuntu