我已经在 Arch Linux 上愉快地使用 KVM 和 virt-manger 大约一年了。今天早上,我的一个虚拟机坏了(这是另一个我认为不相关的故事),我决定删除它并再次进行虚拟安装是最简单的。
但是,通过 virt-manager 界面删除该虚拟机后,我无法再启动 virt-manager:
$ virt-install
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-install", line 15, in <module>
import virtinst
File "/usr/share/virt-manager/virtinst/__init__.py", line 49, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 779, in exec_module
File "<frozen importlib._bootstrap_external>", line 911, in get_code
File "<frozen importlib._bootstrap_external>", line 580, in _compile_bytecode
EOFError: marshal data too short
看来 libxml2 在某种程度上被破坏了:
Python 3.8.3 (default, May 17 2020, 18:15:42)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 779, in exec_module
File "<frozen importlib._bootstrap_external>", line 911, in get_code
File "<frozen importlib._bootstrap_external>", line 580, in _compile_bytecode
EOFError: marshal data too short
我尝试过更新我的系统以及删除并重新安装明显的软件包 、libvirt
、virt-manager
和,libxml2
但这libvirt-python
并没有帮助,也没有有点危险pacman -Syyu
。
关于这里可能会被破坏的任何想法吗?
我使用的是 LTS 内核 5.4。 Python版本是3.8。 Virt-manager 是 2.2.1
另外,如果我刚刚启动 python,我可以毫无问题地加载上述错误中提到的所有模块。
我几乎只是进行一次干净的重新安装,但这是一个可怕的麻烦,如果我可以修复 Arch 中的一些依赖项,我想避免它
编辑:正如评论中所建议的,我尝试运行 strace,这是输出(也许如果我看它足够长的时间,我会对哪个文件可能已损坏有一些了解)。文件损坏似乎确实可能是因为我的根磁盘空间不足。
~]$ strace python -c 'import libxml2'
#output was too big to paste in here, so I cut out everything but the last part, which is what seemed most likely to be relevant
###..........many lines deleted....####
###..........many lines deleted....####
###..........many lines deleted....####
getcwd("/home/boss", 1024) = 11
stat("/home/boss", {st_mode=S_IFDIR|0750, st_size=3488, ...}) = 0
stat("/home/boss", {st_mode=S_IFDIR|0750, st_size=3488, ...}) = 0
stat("/home/boss", {st_mode=S_IFDIR|0750, st_size=3488, ...}) = 0
openat(AT_FDCWD, "/home/boss", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0750, st_size=3488, ...}) = 0
getdents64(3, /* 41 entries */, 32768) = 1416
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
stat("/usr/lib/python3.8", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat("/usr/lib/python3.8/lib-dynload", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat("/home/boss/.local/lib/python3.8/site-packages", {st_mode=S_IFDIR|0700, st_size=3488, ...}) = 0
stat("/usr/lib/python3.8/site-packages", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat("/usr/lib/python3.8/site-packages/libxml2.py", {st_mode=S_IFREG|0644, st_size=345896, ...}) = 0
stat("/usr/lib/python3.8/site-packages/libxml2.py", {st_mode=S_IFREG|0644, st_size=345896, ...}) = 0
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/__pycache__/libxml2.cpython-38.pyc", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=139264, ...}) = 0
ioctl(3, TCGETS, 0x7fffbe383200) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR) = 0
lseek(3, 0, SEEK_CUR) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=139264, ...}) = 0
mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2172e15000
read(3, "U\r\r\n\0\0\0\0\203\224\246^(G\5\0\343\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 139265) = 139264
read(3, "", 1) = 0
close(3) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2172dd5000
write(2, "Traceback (most recent call last"..., 35Traceback (most recent call last):
) = 35
write(2, " File \"<string>\", line 1, in <m"..., 39 File "<string>", line 1, in <module>
) = 39
openat(AT_FDCWD, "<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 68 File "<frozen importlib._bootstrap>", line 991, in _find_and_load
) = 68
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 77 File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
) = 77
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 68 File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
) = 68
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 74 File "<frozen importlib._bootstrap_external>", line 779, in exec_module
) = 74
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 71 File "<frozen importlib._bootstrap_external>", line 911, in get_code
) = 71
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, " File \"<frozen importlib._boots"..., 80 File "<frozen importlib._bootstrap_external>", line 580, in _compile_bytecode
) = 80
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python38.zip/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/boss/.local/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python3.8/site-packages/<frozen importlib._bootstrap_external>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "EOFError: marshal data too short"..., 33EOFError: marshal data too short
) = 33
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f21734763e0}, {sa_handler=0x7f21736ca3a2, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f21734763e0}, 8) = 0
munmap(0x7f2172dd5000, 262144) = 0
munmap(0x7f2172e15000, 143360) = 0
sigaltstack(NULL, {ss_sp=0x5610230bc580, ss_flags=0, ss_size=16384}) = 0
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}, NULL) = 0
exit_group(1) = ?
+++ exited with 1 +++
编辑:
这个线程看起来很有希望,但我不知道在哪里检查是否__init__.py
丢失。
答案1
原因很可能是.pyc
文件损坏。
尝试strace
使用 python 进程,查看import libxml2
它在编组错误之前打开的文件。
然后,再次删除该文件(Python 不需要.pyc
存在文件即可工作)import libxml2
。如果导入成功,请将python-libxml2
其删除并重新安装(这应该会重新生成有错误的.pyc
文件)。