Python에서 libxml2를 가져오지 못하는 문제로 인해 Virt-Manager를 시작할 수 없습니다.

Python에서 libxml2를 가져오지 못하는 문제로 인해 Virt-Manager를 시작할 수 없습니다.

저는 약 1년 동안 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및 을 제거하고 다시 설치해 보았지만 도움 libxml2libvirt-python되지 않으며 조금 위험하지도 않습니다 pacman -Syyu.

여기서 무엇이 문제가 될 수 있는지에 대한 아이디어가 있습니까?

LTS 커널 5.4를 사용하고 있습니다. 파이썬 버전은 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파일 손상일 가능성이 높습니다.

stracePython 프로세스를 사용해 보고 import libxml2마샬링 오류가 발생하기 전에 어떤 파일을 열었는지 확인하세요.

.pyc그런 다음 파일을 다시 삭제합니다(Python은 작동하기 위해 파일이 존재할 필요가 없습니다 ) import libxml2. 가져오기가 성공하면 제거 python-libxml2하고 다시 설치하십시오(이렇게 하면 .pyc오류가 있는 파일이 다시 생성됩니다).

관련 정보