找不到平台无关的库 <prefix>

zjf*_*fdu 6 python conda

我的 travis 工作遇到了以下问题:

Process Output:Could not find platform independent libraries <prefix>
Process Output:Could not find platform dependent libraries <exec_prefix>
Process Output:Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Process Output:Fatal Python error: Py_Initialize: Unable to get the locale encoding
Process Output:ModuleNotFoundError: No module named 'encodings'
Run Code Online (Sandbox Code Playgroud)

我已经尝试设置 PYTHONPATH 和 PYTHONHOME,但仍然不起作用。有人可以帮我吗?谢谢

export PYTHONHOME='$HOME/miniconda'
export PYTHONPATH='$HOME/miniconda:$PYTHONPATH'
Run Code Online (Sandbox Code Playgroud)

Pau*_*ora 6

当您删除默认的 python 库并且不替换它时,就会发生这种情况。例如,遵循不完整的升级说明时。我遇到了这个问题并在 ubuntu 上像这样解决了它(在其他人上应该有类似的过程)...

我使用(我知道过度使用 sudo )安装了新的 python:

$ sudo apt-get update
$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

$ cd /usr/src
$ sudo wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

$ sudo tar xzf Python-2.7.13.tgz
$ cd Python-2.7.13
$ sudo ./configure
$ sudo make install
Run Code Online (Sandbox Code Playgroud)

这为我在 /usr/local/lib 和 /usr/local/bin 中创建了一个 python2.7 。然后我删除了 /usr/lib/ 中的系统 python,认为我不想要两个版本,结果就崩溃了。因为新的 python 位于 /usr/lib/local 中,而系统正在 /usr/lib/ 中查找。

$ cd /usr/lib
$ sudo rm -rf python2.7
Run Code Online (Sandbox Code Playgroud)

删除系统 python 库后出现的具体错误是:

$ sudo apt-get install python-httplib2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-httplib2 is already the newest version (0.8-2build1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-httplib2 (0.8-2build1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing package python-httplib2 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python-httplib2
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

要解决此问题,请将系统 python 替换为新安装的 python(我之前做了前两个,但我想在此处显示正确的 python 交换):

$ cd /usr/lib
$ sudo rm -rf python2.7
$ sudo ln -s /usr/local/lib/python2.7 python2.7

$ cd /usr/bin
$ sudo rm python2.7
$ sudo ln -s /usr/local/bin/python python2.7
Run Code Online (Sandbox Code Playgroud)

然后事情又恢复正常了……

$ sudo apt-get install python-httplib2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-httplib2 is already the newest version (0.8-2build1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-httplib2 (0.8-2build1) ...
Run Code Online (Sandbox Code Playgroud)