![dpkg:无法恢复的致命错误,中止,'python2.7-dev'缺少最后的换行符,ubuntu 18.04](https://linux22.com/image/909782/dpkg%EF%BC%9A%E6%97%A0%E6%B3%95%E6%81%A2%E5%A4%8D%E7%9A%84%E8%87%B4%E5%91%BD%E9%94%99%E8%AF%AF%EF%BC%8C%E4%B8%AD%E6%AD%A2%EF%BC%8C'python2.7-dev'%E7%BC%BA%E5%B0%91%E6%9C%80%E5%90%8E%E7%9A%84%E6%8D%A2%E8%A1%8C%E7%AC%A6%EF%BC%8Cubuntu%2018.04.png)
跑步后
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