add-apt-repository 报错 cannot import name '_gi' from 'gi'

https://stackoverflow.com/questions/59389831/cannot-import-name-gi#comment108816661_59389914

ubuntu 18.0.4
python 3.7
使用add-apt-repository命令出错

报错信息:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in 
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 67, in 
    from gi.repository import Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

解决方法

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

你可能感兴趣的:(add-apt-repository 报错 cannot import name '_gi' from 'gi')