Python 循环导入模块 _gi 导致 apt-add-repository 命令在 linux 中失败
Python Circular Import Module _gi causes apt-add-repository command to fail in linux
我今天尝试添加一个存储库时发现一个我似乎无法解决的奇怪错误。
我正在尝试执行此命令
sudo apt-add-repository ppa:fish-shell/release-3
当它总是返回这个错误信息时
Traceback (most recent call last):
File "/usr/bin/apt-add-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 partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)
我试过用这个命令诊断它
sudo update-alternatives --config python3
它显示了这个
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/bin/python3.8
Nothing to configure.
我也试过 /usr/lib/python3/dist-packages/gi
并使用此命令添加一个符号 link
sudo ln -s _gi.cpython-{36m,37m}-x86_64-linux-gnu.so
还是不行
我已经尝试将正确的 python 版本添加到 /usr/bin/apt-add-repository
我也试过用
python3 -m pip install gi
Could not find a version that satisfies the requirement gi (from versions: )
No matching distribution found for gi
如何解决这个烦人的错误?
完成:
sudo apt-get install graphviz
代码:
import objgraph
import random
import io
from graphviz import Source
from io import StringIO
q = StringIO()
#objgraph.show_refs([SAFE_TAGS], output=s)
objgraph.show_chain(
objgraph.find_backref_chain(
random.choice(objgraph.by_type('dict')),
objgraph.is_proper_module),
output=q)
q.seek(0)
Source(q.read())
chart
我今天尝试添加一个存储库时发现一个我似乎无法解决的奇怪错误。
我正在尝试执行此命令
sudo apt-add-repository ppa:fish-shell/release-3
当它总是返回这个错误信息时
Traceback (most recent call last):
File "/usr/bin/apt-add-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 partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)
我试过用这个命令诊断它
sudo update-alternatives --config python3
它显示了这个
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/bin/python3.8
Nothing to configure.
我也试过 /usr/lib/python3/dist-packages/gi 并使用此命令添加一个符号 link
sudo ln -s _gi.cpython-{36m,37m}-x86_64-linux-gnu.so
还是不行
我已经尝试将正确的 python 版本添加到 /usr/bin/apt-add-repository
我也试过用
python3 -m pip install gi
Could not find a version that satisfies the requirement gi (from versions: )
No matching distribution found for gi
如何解决这个烦人的错误?
完成:
sudo apt-get install graphviz
代码:
import objgraph
import random
import io
from graphviz import Source
from io import StringIO
q = StringIO()
#objgraph.show_refs([SAFE_TAGS], output=s)
objgraph.show_chain(
objgraph.find_backref_chain(
random.choice(objgraph.by_type('dict')),
objgraph.is_proper_module),
output=q)
q.seek(0)
Source(q.read())
chart