带有“--enable-shared"的奇怪 Python 编译结果旗帜 [英] Strange Python compilation results with "--enable-shared" flag

查看:39
本文介绍了带有“--enable-shared"的奇怪 Python 编译结果旗帜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Debian(Python-2.7.3 附带),尝试从源代码编译 Python-2.7.6,以便与 mod_wsgi 和 Apache 一起使用.

I am using Debian (which comes with Python-2.7.3), trying to compile Python-2.7.6 from source for use with mod_wsgi alongside Apache.

根据众多答案,显然您必须在编译 mod_wsgi 使用时使用 --enable-shared.

Apparently you must use --enable-shared when compiling for mod_wsgi usage, according to numerous answers.

按照以下步骤操作:

./configure --enable-shared --prefix=/usr/local/bin/python-2.7.6
make
make install

然后检查交互式shell @

And then checking the interactive shell @

/usr/local/bin/python-2.7.6/bin/python

/usr/local/bin/python-2.7.6/bin/python

我受到Python 2.7.3(默认,2013 年 1 月 2 日,14:09:21)"等的欢迎

I am greeted with "Python 2.7.3 (default, Jan 2 2013, 14:09:21)" etc

为什么会导致 Python 2.7.3?

Why is it resulting in Python 2.7.3?

我对可执行文件尝试了 ldd,结果如下:

I tried ldd against the executable and this is the result:

linux-vdso.so.1 =>  (0x00007fff271ff000)
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f1545638000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f154541c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1545217000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f1545014000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1544d92000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1544a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f15447ef000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15445d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1545b40000)

如何阻止它使用系统库而使用本地编译的版本?

How do I stop it from using the system library and instead use the locally compiled version?

我知道恢复使用系统安装的 Python 版本要容易得多,而且现实世界的差异为零.但这种行为似乎很奇怪.

I know that it is a lot easier for me to just revert to using the system installed Python version, and that the real-world difference is zero. But this behaviour seems strange.

推荐答案

当你做 Python 的 make 时,运行如下:

When you do the make of Python, run it as:

LD_RUN_PATH=/usr/local/lib make

设置环境变量 LD_RUN_PATH 会强制生成的python"可执行文件在/usr/lib 之前的/usr/local/lib 中查找 Python 共享库.

Setting the environment variable LD_RUN_PATH forces 'python' executable generated to look in /usr/local/lib before /usr/lib for Python shared library.

这在 mod_wsgi 文档中有所提及.

This is mentioned in the mod_wsgi documentation.

在再次执行此操作之前,请确保执行make distclean"并重新运行配置以确保您没有旧的构建产品.

Before doing this again, make sure you do a 'make distclean' and rerun configure to make sure you haven't got old build products around.

这篇关于带有“--enable-shared"的奇怪 Python 编译结果旗帜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆