跑步后
sudo apt upgrade
我收到以下错误:
dpkg: unrecoverable fatal error, aborting:
files list file for package 'python2.7-dev' is missing final newline.
E: Sub-process /usr/bin/dpkg returned an error code (2)
如果我运行:
sudo apt install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7-dev is already the newest version (2.7.15~rc1-1ubuntu0.1).
如果我尝试删除任何其他包,我会遇到同样的错误:
dpkg: unrecoverable fatal error, aborting:
files list file for package 'python2.7-dev' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)
有人可以帮忙解决这个问题吗?
答案1
在终端(++)中输入以下内容应该Ctrl可以解决您的问题:AltT
(像这样重命名您找到的所有“python2.7”文件/var/lib/dpkg/info/
:(查找其他文件,我仅展示了如何重命名那些显然存在的文件))
sudo mv /var/lib/dpkg/info/python2.7.postinst /var/lib/dpkg/info/python2.7.postinst.bak &&
sudo mv /var/lib/dpkg/info/python2.7.list /var/lib/dpkg/info/python2.7.list.bak &&
sudo mv /var/lib/dpkg/info/python2.7.postinst /var/lib/dpkg/info/python2.7-dev.postinst.bak &&
sudo mv /var/lib/dpkg/info/python2.7.list /var/lib/dpkg/info/python2.7-dev.list.bak &&
sudo dpkg --configure -a &&
sudo apt clean &&
sudo apt autoremove &&
sudo apt update &&
sudo apt dist-upgrade
如果此方法有效,您可以删除重命名的文件:
sudo rm /var/lib/dpkg/info/python2.7*.bak