[英]Compile Python 2.7.3 from source on a system with Python 2.7 already
I wish to compile Python 2.7.3 from source. 我希望从源代码编译Python 2.7.3。 The OS is OpenSUSE 11.4 x86_64, which already provides Python 2.7. 操作系统是OpenSUSE 11.4 x86_64,已经提供了Python 2.7。 I'd like to use 2.7.3 for the latest security patches, but it's a shared system so I can't tinker with the system Python interpreter. 我想将2.7.3用于最新的安全补丁,但它是一个共享系统,所以我不能修改系统Python解释器。
I compile using ./configure --prefix=/opt/python --enable-shared
. 我使用./configure --prefix=/opt/python --enable-shared
编译。 No configure errors, so I make
. 没有配置错误,所以我make
。 Again no errors. 再没有错误。 I do a make install
(I don't think I need make altinstall
, since this installation prefix in /opt/python
isn't in use yet). 我做make install
(我认为我不需要make altinstall
,因为/opt/python
安装前缀尚未使用)。
When I try to run the new binary /opt/python/bin/python
, Python announces its version as 2.7, not 2.7.3. 当我尝试运行新的二进制文件/opt/python/bin/python
,Python宣布其版本为2.7,而不是2.7.3。 The only way I've found to correct this is to move the system's /usr/lib64/libpython2.7.so.1.0
, and symlink it to /opt/python/lib/python/libpython2.7.so.1.0
. 我发现纠正这个问题的唯一方法是移动系统的/usr/lib64/libpython2.7.so.1.0
,并将其符号链接到/opt/python/lib/python/libpython2.7.so.1.0
。 This works and Python announces it is 2.7.3, but this breaks the system Python. 这是有效的,Python宣布它是2.7.3,但这打破了系统Python。
Is there anyway I can get the two to coexist, eg by getting the /opt/python
to use its own libpython? 无论如何我可以让两者共存,例如让/opt/python
使用自己的libpython吗? Other than supplying LD_LIBRARY_PATH at runtime. 除了在运行时提供LD_LIBRARY_PATH。 Is there a compile time solution? 有编译时解决方案吗? Thanks. 谢谢。
To avoid having to specify the runtime library path using LD_LIBRARY_PATH
each time Python is started, you can specify it at build time using the -rpath
linker option: 为避免每次启动Python时都必须使用LD_LIBRARY_PATH
指定运行时库路径,可以使用-rpath
链接器选项在构建时指定它:
./configure --enable-shared --prefix=/opt/python \
LDFLAGS=-Wl,-rpath=/opt/python/lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.