我正在尝试使用 add-apt-repository
向 ppa 添加存储库命令,但 _gi
未找到来自 Python 的模块。
我做了这个命令:sudo add-apt-repository ppa:s-mankowski/ppa-kf5
这是回溯:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 67, in <module>
from gi.repository import Gio
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
我在使用 Python3.7 的 Ubuntu 上,我尝试了许多解决方案,但它不起作用:
$ cd /usr/lib/python3/dist-packages
$ sudo ln -s apt_pkg.cpython-{36m,37m}-x86_64-linux-gnu.so
$ cd /usr/lib/python3/dist-packages/gi
$ sudo ln -s _gi.cpython-{36m,37m}-x86_64-linux-gnu.so
我无法使用
sudo add-apt-repository ppa:s-mankowski/ppa-kf5
命令,但使用 python3 {file}
运行 Python 文件作品。谢谢您的帮助 !
最佳答案
感谢 a comment by Wilhelm ,我发现解决方法是:
sudo ln -s /usr/lib/python3/dist-packages/gi/_gi.cpython-{36m,37m}-x86_64-linux-gnu.so
这对我在 Ubuntu 上使用 Python 3.7 有效。
关于python - 无法导入名称 '_gi',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59389831/