dpkg 和 sudo apt-get update 的问题

dpkg 和 sudo apt-get update 的问题

当我写作时,dpkg --configure -a我得到了这个错误:

dpkg: error processing package python-numpy (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-pil:amd64 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python-scipy:
 python-scipy depends on python-numpy (>= 1:1.13.1); however:
  Package python-numpy is not configured yet.
 python-scipy depends on python-numpy-abi9; however:
  Package python-numpy-abi9 is not installed.
  Package python-numpy which provides python-numpy-abi9 is not configured yet.

dpkg: error processing package python-scipy (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-matplotlib:
 python-matplotlib depends on python-numpy (>= 1:1.13.1); however:
  Package python-numpy is not configured yet.
 python-matplotlib depends on python-numpy-abi9; however:
  Package python-numpy-abi9 is not installed.
  Package python-numpy which provides python-numpy-abi9 is not configured yet.

dpkg: error processing package python-matplotlib (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-numpy
 python-pil:amd64
 python-scipy
 python-matplotlib

我关注了,但 sudo apt-get update我收到错误:

Hit:8 https://packages.microsoft.com/repos/ms-teams stable InRelease           
Get:9 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]    
Fetched 88.7 kB in 1s (98.6 kB/s)                              
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f5953b88740 (most recent call first):
Aborted (core dumped)
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

请问您知道可能出了什么问题吗?

最初,我尝试重新安装 Python,但由于<prefix>问题(在第二个错误输出中)而无法完成。

答案1

备份您的status文件:

sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.bak

/var/lib/dpkg/status通过删除python-numpypython-pil:amd64python-scipy及其python-matplotlib描述进行编辑,然后运行sudo dpkg --configure -a

要解决以下错误:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

參閱stackoverflow 上的此问答

相关内容