简体   繁体   English

Python3.6:导入 gi 模块时出错

[英]Python3.6: Error importing gi module

I'm having problem importing gi module in python3.6.我在 python3.6 中导入gi模块时遇到问题。 When importing it using python3.5 it works fine but when using python3.6 I get:使用 python3.5 导入时,它工作正常,但使用 python3.6 时,我得到:

ImportError: cannot import name '_gi'导入错误:无法导入名称“_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:我在尝试从 miniconda python3.7 导入 gi 时也遇到了这个问题,并通过执行以下操作来修复它:

First, create a symlink to gi module in your system python.首先,在你的系统 python 中创建一个指向 gi 模块的符号链接。 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.我的系统python是python3.5,miniconda python是python3.7。 Your version is 3.6, so take care of that in the commands above (-35m- and -37m-).您的版本是 3.6,因此请在上面的命令(-35m- 和 -37m-)中注意这一点。

Method obtained from this link https://askubuntu.com/questions/1057832/how-to-install-gi-for-anaconda-python3-6从此链接获得的方法https://askubuntu.com/questions/1057832/how-to-install-gi-for-anaconda-python3-6

Hope this helps.希望这会有所帮助。

Best,最好的,

Aneesh阿尼什

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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