./configure --prefix=/my/local/dir --exec-prefix=/my/local/dir --enable-shared --with-pydebug
make
make install
并且python的输出是/ my / local / dir / bin / python,这是正确的.
但是当我运行python –version时,我看到的是Python 2.7.3而不是Python 2.7.10.
Python的系统版本是2.7.3.难道是Python的系统版本会以某种方式将自身链接到本地编译版本吗?还是我做错了什么?
编辑:
./my/local/dir/bin/python –version的输出也是Python 2.7.3
编辑2:
似乎如果我摆脱了–enable-shared标志,它将生成正确版本的Python,但我需要该标志才能使其他软件正常工作.
解决方法:
If you try to run a –enable-shared python executable from its build directory, you’ll need to tell the dynamic loader where to find the shared library, i.e. the build directory itself. One way to do that is to use the LD_LIBRARY_PATH environment variable. Otherwise, the dynamic loader will search the standard paths, like /usr/local/lib/ and /usr/lib/ for a shared library with the proper name (like libpython2.7.so.1.0). If there is an older Python already installed with that name and if the ABI hasn’t changed too much, you may be lucky and it will load and run.