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

时间:2017-07-09 01:45:41

标签: 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'

我已经尝试过设置PYTHONPATH和PYTHONHOME,但仍然无法正常工作。有人可以帮我吗?感谢

export PYTHONHOME='$HOME/miniconda'
export PYTHONPATH='$HOME/miniconda:$PYTHONPATH'

1 个答案:

答案 0 :(得分:3)

当您删除默认的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

这为我在/ 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

删除系统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)

要解决此问题,请使用新安装的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

然后事情再次起作用......

$ 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) ...