安装完成,进入 /home/steven/python-2.7/bin/python 命令行,发现 Python 变成了 2.7.5。安装过程中既没有报错,也没有其他任何的 warnning 信息。重装过程中甚至使用 make test 进行了检测,Tests result: SUCCESS!问题依然无法解决。
$ /home/steven/python-2.7/bin/python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
开始怀疑是个人 home 目录或者系统 env 的影响,但检查了很多遍,甚至清空了所有的 env,更换其他用户,更换 Python-2.7.14 安装,结果都一样。毫无头绪之下,调整编译尝试最简安装:
$ ./configure --prefix=/home/steven/python-2.7
$ make
$ make install
The problem is, that on most Unix systems (with the notable exception of Mac OS X), the path to shared libraries is not an absolute path. So, if you install Python in a non-standard location, which is the right thing to do so as not to interfere with a system Python of the same version, you will need to configure in the path to the shared library or supply it via an environment variable at run time, like LD_LIBRARY_PATH. You may be better off avoiding –enable-shared; it’s easy to run into problems like this with it.