如何解析库问题?

如何解析库问题?

当我运行用 Python 编写的代码时,我得到:

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' 

我试过

  1. export PYTHONHOME=/usr/lib/Python以及我希望库所在的所有其他位置 dist-packages(因为我不能使用 Python,所以我无法使用 Python 来告诉我库在哪里)。
  2. 从这里提示但回应virtualenv -p /usr/bin/python3 venv/是:
ImportError: No module named site
  1. sudo apt-get install --reinstall python但我得到了这个: Processing was halted because there were too many errors.- 在这一行之前写了很多错误,所以只是一个例子:
dpkg: error processing package dh-python (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
                                                                    dpkg: dependency problems prevent configuration of mugshot:
 mugshot depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package mugshot (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
                                                                    Setting up python (2.7.15~rc1-1) ...
dpkg: dependency problems prevent configuration of onboard:
 onboard depends on onboard-common (<< 1.4.1-2ubuntu1.1); however:
  Package onboard-common is not configured yet.
 onboard depends on onboard-common (>= 1.4.1-2ubuntu1); however:
  Package onboard-common is not configured yet.
 onboard depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 onboard depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 onboard depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package onboard (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
                                                                    No apport report written because MaxReports has already been reached
                                                        dpkg: dependency problems prevent configuration of redshift-gtk:
 redshift-gtk depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
  1. 然后我尝试了一下sudo dpkg --configure -a,但得到了与第 3 点相同的错误。

  2. (奖励):有趣的是,当我写 pip(我用它来安装库)时,我得到了 ImportError: No module named site

请问您有什么建议可以尝试吗?

PS:Askubuntu 似乎是最好的提问论坛,因为对我来说,它看起来更像是“内部”问题(我可能删除了某些内容?)而不是 Python。如果不是,请将我引荐到正确的论坛。

答案1

在我尝试了所有我能尝试的方法后,结论是:太多依赖关系被破坏了。因此,我决定重新安装 Linux - 如果我知道重新安装的速度有多快,我就不会花几天时间去寻找错误了。 本手册一目了然,对 Linux 新手来说很棒。但我学到了很多东西。

我学到的主要东西是:不要删除任何你不知道它是什么或它有什么作用的东西!:)

相关内容