由于依赖关系导致更新或升级 ubuntu 时出错

由于依赖关系导致更新或升级 ubuntu 时出错

当我安装或更新任何东西时,我都会收到类似下面这样的错误。

我可以强制完全卸载这些软件包或其他类似选项以避免这些错误吗?

为此,我使用了 synaptic,但我也尝试使用 apt install 或 remove

sudo apt-get --force-yes remove ...

错误提示:

...
dpkg: warning: files list file for package 'python-pysqlite2' missing; assuming package has no files currently installed
(Reading database ... 470240 files and directories currently installed.)
Removing python-mysql.connector (2.0.4-1) ...
/var/lib/dpkg/info/python-mysql.connector.prerm: 6: /var/lib/dpkg/info/python-mysql.connector.prerm: pyclean: not found
dpkg: error processing package python-mysql.connector (--remove):
 subprocess installed pre-removal script returned error exit status 127
/var/lib/dpkg/info/python-mysql.connector.postinst: 6: /var/lib/dpkg/info/python-mysql.connector.postinst: pycompile: not found
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 python-mysql.connector
E: Sub-process /usr/bin/dpkg returned an error code (1)
...

错误突触:

E: python-ecdsa: subprocess installed post-installation script returned error exit status 127
E: python-mysql.connector: subprocess installed post-installation script returned error exit status 127
E: python-ptyprocess: subprocess installed post-installation script returned error exit status 127

答案1

您可能需要重新安装损坏的软件包,因为这可能是由于软件安装不正确造成的。

for package in $(sudo apt-get upgrade 2>&1 | grep "warning: files list file for package '" | grep -Po "[^'\n ]+'" | grep -Po "[^']+"); do sudo apt-get install --reinstall "$package"; done

warning: files list file for package此脚本重新安装过程中输出的每个包apt-get upgrade

由于每个包裹都会循环,因此需要更长的时间。

如果脚本不起作用,那么您应该对每个python-pysqlite2显示上述警告的包(当前为)执行类似的操作:

sudo apt-get install --reinstall python-pysqlite2

来源

相关内容