我尝试通过下载源代码在 OpenSuSE Linux 上手动安装 Python,然后运行:
configure --prefix=/path/to/my/dir/installed/python
和
make && make install
(我必须这样做,因为我使用的是我的机构提供的服务器,而我没有 root 访问权限)
这给了我以下警告:
make: warning: Clock skew detected. Your build may be incomplete.
我不确定警告是否与我将来遇到的错误有关。(编辑:这个警告现在消失了)
我检查了安装日志,我意识到它给了我以下错误:
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/path/to/my/dir/installed/python/include -I. -IInclude -I./Include -I/usr/local/include -I/path/to/my/dir/setup/Python-2.7.11/Include -I/path/to/my/dir/setup/Python-2.7.11 -c /path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.c -o build/temp.linux-x86_64-2.7/path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.o
/path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.c:17:19: fatal error: panel.h: No such file or directory
#include <panel.h>
^
compilation terminated.
Python build finished, but the necessary bits to build these modules were not found:
bsddb185 dl imageop
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
现在我运行 python
/path/to/my/dir/installed/python/bin/python
它给了我以下错误:
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python 2.7.13 (default, May 26 2017, 18:16:53)
[GCC 4.8.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/etc/pythonstart", line 7, in <module>
import readline
ImportError: No module named readline
我尝试使用How can I Troubleshoot Python "Could not find platform Independent libraries <prefix>"以及一些类似的链接来修复此错误,并将我的环境变量设置为:
export PYTHONPATH='/path/to/my/dir/installed/python/lib/:/path/to/my/dir/installed/python/lib/lib-dynload:/path/to/my/dir/installed/python/lib/python2.7/site-packages'
export PYTHONHOME='/path/to/my/dir/installed/python/lib
现在,如果我运行 python,它会给我这个错误:
ImportError: No module named site
我在 Stackoverflow 上搜索后一种解决方案,但他们只是告诉我回去取消设置$PYTHONHOME
and $PYTHONPATH
...
我还尝试将两条路径重置到其他一些位置,但都不起作用。
供您参考,如果我取消设置路径并运行 python,它仍然会输出之前的“找不到依赖库”错误,如果我尝试找到它提供的路径:
>>>import sys
>>>sys.path
['', '/path/to/my/dir/installed/python/lib/python27.zip',
'/path/to/my/dir/installed/python/lib/python2.7',
'/path/to/my/dir/installed/python/lib/python2.7/plat-linux2',
'/path/to/my/dir/installed/python/lib/python2.7/lib-tk',
'/path/to/my/dir/installed/python/lib/python2.7/lib-old',
'/path/to/my/dir/installed/python/lib/lib-dynload',
'/path/to/my/dir/installed/python/lib/python2.7/site-packages']