Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3.6: Error importing gi module

I'm having problem importing gi module in python3.6. When importing it using python3.5 it works fine but when using python3.6 I get:

ImportError: cannot import name '_gi'

How can I fix this?

like image 658
jimmy Avatar asked Jan 03 '23 14:01

jimmy


1 Answers

I also faced this issue while trying to import gi from miniconda python3.7 and fixed it by doing the following:

First, create a symlink to gi module in your system python. For me, the command is as follows:

ln -s /usr/lib/python3/dist-packages/gi/ /home/$USER/miniconda3/lib/python3.7/site-packages/

Then, open the directory

cd /home/$USER/miniconda3/lib/python3.7/site-packages/gi/

and run the following commands:

sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-37m-x86_64-linux-gnu.so

My system python is python3.5 and miniconda python is python3.7. Your version is 3.6, so take care of that in the commands above (-35m- and -37m-).

Method obtained from this link https://askubuntu.com/questions/1057832/how-to-install-gi-for-anaconda-python3-6

Hope this helps.

Best,

Aneesh

like image 84
Aneesh Palsule Avatar answered Jan 16 '23 07:01

Aneesh Palsule