我在执行与 ValueError: bad marshal data 相关的正常 ubuntu(18) 更新时遇到错误
我按照建议删除了 /usr 中的 pyc 文件,但没有成功。我尝试删除并重新安装 python - 但遇到了这个问题:
jon@:/var/www/stats/pup$ sudo apt install --reinstall python3-apt
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
apport : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed
apport-gtk : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我尝试了 apt --fix-broken install 但是失败了:
(Reading database ... 320885 files and directories currently installed.)
Preparing to unpack .../python3-apport_2.20.9-0ubuntu7.21_all.deb ...
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1159, in _install
ValueError: bad marshal data (unknown type code)
Fatal Python error: Py_Initialize: importlib install failed
Current thread 0x00007fd7fedd1740 (most recent call first):
Aborted
dpkg: warning: old python3-apport package pre-removal script subprocess returned error exit status 134
dpkg: trying script from the new package instead ...
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1159, in _install
ValueError: bad marshal data (unknown type code)
Fatal Python error: Py_Initialize: importlib install failed
Current thread 0x00007f5f2bcdf740 (most recent call first):
Aborted
dpkg: error processing archive /var/cache/apt/archives/python3-apport_2.20.9-0ubuntu7.21_all.deb (--unpack):
new python3-apport package pre-removal script subprocess returned error exit status 134
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1159, in _install
ValueError: bad marshal data (unknown type code)
Fatal Python error: Py_Initialize: importlib install failed
Current thread 0x00007faebc356740 (most recent call first):
Aborted
dpkg: error while cleaning up:
installed python3-apport package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
/var/cache/apt/archives/python3-apport_2.20.9-0ubuntu7.21_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
删除 python 从来都不是一个好主意,因为它对于系统的功能至关重要。
我建议安装 aptitude 并使用它来安装 python3,以便 APT 再次正常工作。Aptitude 擅长解决依赖关系,在类似情况下,它已在删除 python3 后成功安装。
如果解决方案这个帖子对你来说不起作用,我建议你尝试从实时 USB 修复(比如你用来安装 Ubuntu 的 USB)。
要从实时 USB 修复,请启动实时系统并选择尝试 Ubuntu然后从实时系统连接到互联网并打开终端,然后按照以下步骤操作:
跑步:
sudo fdisk -l
并确定你的根分区。它可能类似于然后/dev/sda1
将其挂载到/mnt
:
sudo mount /dev/sda1 /mnt/
然后运行:
sudo mount --bind /proc/ /mnt/proc/
然后运行:
sudo mount --bind /sys/ /mnt/sys/
然后运行:
sudo mount --bind /dev/ /mnt/dev/
然后运行:
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
然后运行:
sudo chroot /mnt/
现在您位于硬盘上的原始系统中。运行以下命令:
sudo dpkg --configure -a && sudo apt update --fix-missing && sudo apt install -f --fix-broken
aptitude
然后像这样安装:
sudo apt install aptitude
如果这不起作用,请.deb
从以下位置下载 aptitude 包这里对于 64 位,如下所示:
sudo wget http://mirrors.kernel.org/ubuntu/pool/main/a/aptitude/aptitude_0.8.10-6ubuntu1_amd64.deb
像这样安装:
sudo dpkg -i aptitude_0.8.10-6ubuntu1_amd64.deb
然后运行:
sudo aptitude install python3
运行完毕后:
exit
然后运行:
sudo umount /mnt/dev/
然后运行:
sudo umount /mnt/sys/
然后运行:
sudo umount /mnt/proc/
然后运行:
sudo umount /mnt/
然后重新启动到原始系统,看看问题是否已解决。如果此方法无效,您可能需要重新安装 Ubuntu。
重要的:
如果您发现没有任何效果并且决定重新安装 Ubuntu,请确保先将所有重要数据备份到外部磁盘。
另外,为了尽量减少丢失设置,请复制您的主目录(/home/用户名/)以及所有隐藏的目录和文件到外部磁盘,然后在新安装后将其复制回来。这将保留您的大部分应用程序设置,例如 Firefox、Thunderbird 等,但您需要重新安装您手动安装的应用程序和软件包才能使其正常工作。