gpt4 book ai didi

python - 找不到与平台无关的库

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:36 27 4
gpt4 key购买 nike

我的 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'

最佳答案

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

关于python - 找不到与平台无关的库 <prefix>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44992246/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com