我正在对我的系统进行 dist-upgrade,但有些事情没有按预期进行,而且我在做其他工作的同时还在运行升级。
结果 Python 3 搞乱了,我无法运行 apt 更新,也无法升级系统
错误信息:
dpkg: error processing package python3 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Käsittelyssä tapahtui liian monta virhettä:
python3
E: Sub-process /usr/bin/dpkg returned an error code (1)
我的命令行历史记录:
276 sudo apt-get update && sudo apt-get dist-upgrade
277 sudo apt-get dist-upgrade
278 sudo apt autoremove
279 sudo apt-get dist-upgrade
280 man apt
281 man dist-upgrade
282 sudo do-release-upgrade
283 /usr/bin/python3
284 sudo do-release-upgrade
285 sudo rm /usr/bin/python
286 sudo ln -s /usr/bin/python2.7 /usr/bin/python
287 sudo do-release-upgrade
288 sudo ln -sf /usr/bin/python2.7 /usr/bin/python
289 sudo do-release-upgrade
290 sudo update-alternatives --remove-all python
291 sudo update-alternatives --remove-all python3
292 sudo ln -sf /usr/bin/python3.6 /usr/bin/python3
293 sudo do-release-upgrade
294 sudo apt-get install --reinstall python3
295 sudo do-release-upgrade
296 sudo dpkg --remove --force-remove-reinstreq --force-depends python3
297 sudo apt-get -f install
298 sudo do-release-upgrade
299 sudo apt-get update
300 sudo apt-get upgrade
301 sudo apt-get reinstall python3
302 man apt-get
303 sudo apt-get install python3 --reinstall
304 sudo ln -sf /usr/bin/python2.7 /usr/bin/python
305 sudo apt-get install python3 --reinstall
306 sudo do-release-upgrade
307 history
308 update-manager
309 sudo apt-get update && sudo apt-get upgrade
310 sudo apt-get install python3
311 sudo apt-get reinstall python3
312* sudo dpkg --remove --force-remove-reinstr
313 sudo dpkg --remove --force-remove-reinstreq python3 && sudo apt-get install python3
现在我不再记得我当时到底做了什么,因为这件事发生在我休假之前,现在三周过去了,我不再记得到底发生了什么导致了这种情况。
我在这里该怎么办?
答案1
我通过运行解决了这个问题 sudo apt install --reinstall python3 python python3-minimal --fix-broken
结果sudo apt install --reinstall python3 python python3-minimal --fix-broken
:
282 sudo apt-get --reinstall python3
283 sudo apt-get install --reinstall python3
284 sudo apt-get install --reinstall python3
285 man apt-get
286 apt list --installed
287 apt list --installed |grep python
288 apt list --installed |grep python > installed.python.txt
289 ls list*
290 ls inst*
291 less installed.python.txt
292 pwd
293 ls -l `which python`
294 which python3
295 which python
296 ls -la /usr/bin/python
297 history
298 sudo apt-get install --reinstall python3
299 sudo apt-get install --reinstall python
300 sudo apt-get install --reinstall python3
301 sudo apt-get install --reinstall python3-minimal
302 sudo apt-get install --fix-broken
303 sudo apt-get install --reinstall python
304 sudo apt-get install --reinstall python3
305 sudo apt-get install --reinstall python3-minimal
306 sudo apt-get install --fix-broken
307 sudo apt autoremove
308 sudo apt-get update
309 sudo apt-get upgrade
310 sudo reboot
现在一切都按预期进行。
答案2
我遇到了类似的问题,只是有多个 Python 依赖项引发了此错误(sudo make install
而不是sudo make altinstall
在新编译的 Python 版本上使用,存在一些问题)。
我通过运行修复了它
sudo dpkg --remove --force-all python3-smbc python3-entrypoints python3-dbus python3-cairo:armhf python3-setuptools python3-apt python3-olefile python3-debconf python3-yaml python3-xdg python3-wheel python3-cupshelpers python3-six python3-pil:armhf python3-chardet python3-secretstorage python3-certifi python3-cryptography python3-gi python3-requests python3-idna python3-urllib3 python3-reportlab python3-keyrings.alt python3-keyring python3-crypto python3-asn1crypto python3-ptyprocess ssh-import-id python3-pexpect
然后继续重新安装。