Python3

lsb-release 和 python3 (ubuntu 18.04) 之間的循環依賴

  • April 15, 2019

我已經設法陷入了 lsb-release 和 python3 之間存在循環依賴關係的情況。當我嘗試時,sudo apt install python3 --reinstall我得到以下資訊(只是粘貼關鍵行)

(Reading database ... 470097 files and directories currently installed.)
Preparing to unpack .../python3_3.6.7-1~18.04_amd64.deb ...
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'

[~] lsb_release
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 0x00007fa905a81740 (most recent call first):
Aborted (core dumped)

顯然我的 lsb_release 壞了。但是如果我跑sudo apt-get install lsb-release我會得到

dpkg: error processing package python3 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of lsb-release:
lsb-release depends on python3:any (>= 3.4~); however:
 Package python3 is not configured yet.

所以我不能在不修復 lsb-release 的情況下修復我的 python3 安裝,反之亦然。

您可以修復 Python 安裝而不修復lsb_release. 您的 Python 安裝需要重新安裝其他 Python 包;至少

sudo apt install --reinstall libpython3.6-minimal

也許更多。要重新安裝所有軟體包,請執行

sudo apt install --reinstall libpython3.6{,-minimal,-stdlib} python3.6{,-minimal}

然後,您應該會發現lsb_release效果很好。

引用自:https://unix.stackexchange.com/questions/512473