简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM