安装多版本python27并开启enable-shared
来源:互联网 发布:网络摄像头原理 编辑:程序博客网 时间:2024/06/07 13:37
安装多个python27的版本,如果不开启enable-shared,指定不同路径即可。当开启enable-shared时,默认只有一个版本的python。
比如通过gcc4 和 gcc5 分别编译安装python到不同的路径,通过ldd查看关联的库,会发现都指向了同一个libpython2.7.so.1.0。
# 通过gcc4编译安装的python27,指向的是/opt/python27/lib[root@cs-pl-test Python-2.7.2]# ldd /opt/pythonGcc5/bin/python linux-vdso.so.1 => (0x00007ffe027c6000) libpython2.7.so.1.0 => /opt/python27/lib/libpython2.7.so.1.0 (0x00007fc50ae77000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc50ac59000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fc50aa55000) libutil.so.1 => /lib64/libutil.so.1 (0x00007fc50a852000) libm.so.6 => /lib64/libm.so.6 (0x00007fc50a5cd000) libc.so.6 => /lib64/libc.so.6 (0x00007fc50a239000) /lib64/ld-linux-x86-64.so.2 (0x00007fc50b260000)
# 通过gcc5编译安装的python27,指向的也是/opt/python27/lib[root@cs-pl-test Python-2.7.13]# ldd /opt/pythonGcc5/bin/python linux-vdso.so.1 => (0x00007fff057ff000) libpython2.7.so.1.0 => /opt/python27/lib/libpython2.7.so.1.0 (0x00007f4e1b7bc000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4e1b59e000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f4e1b39a000) libutil.so.1 => /lib64/libutil.so.1 (0x00007f4e1b197000) libm.so.6 => /lib64/libm.so.6 (0x00007f4e1af12000) libc.so.6 => /lib64/libc.so.6 (0x00007f4e1ab7e000) /lib64/ld-linux-x86-64.so.2 (0x00007f4e1bba5000)
所以要共存的话,把它们指向的库改成对应的libpython2.7.so.1.0即可。
方法一
在编译时,指定LD_RUN_PATH
LD_RUN_PATH=/usr/local/lib make
比如这里指定了lib库的路径是/usr/local/lib,make后,python的libpython2.7.so.1.0 就指向/usr/local/lib了。注意,这里要先将当前路径下的libpython2.7.so.1.0复制到/usr/local/lib下,之后再make install
cp libpython2.7.so.1.0 /usr/local/lib
再看下该版本的指向,已经是/usr/local/lib了
[root@cs-pl-test Python-2.7.13]# ldd /opt/pythonGcc5/bin/python linux-vdso.so.1 => (0x00007ffea43af000) libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007f971d0fe000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f971ced4000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f971ccd0000) libutil.so.1 => /lib64/libutil.so.1 (0x00007f971cacd000) libm.so.6 => /lib64/libm.so.6 (0x00007f971c848000) libc.so.6 => /lib64/libc.so.6 (0x00007f971c4b4000) /lib64/ld-linux-x86-64.so.2 (0x00007f971d4db000)
方法二
使用工具修改python的libpython2.7.so.1.0指向
本次用patchelf
https://github.com/NixOS/patchelf
先编译安装下这个工具
git clone https://github.com/NixOS/patchelfcd patchelf./bootstrap.sh./configuremakemake install
安装完成后,去到要修改的python路径下,先去掉现有的指向
/opt/patchelf/bin/patchelf --remove-needed libpython2.7.so.1.0 ./python
之后再增加到新路径即可
/opt/patchelf/bin/patchelf --add-needed /usr/local/lib/libpython2.7.so.1.0 ./python
推荐用第一种方法
阅读全文
0 0
- 安装多版本python27并开启enable-shared
- 安装pyenv install时指定enable-shared
- curl开启ssl 安装openssl带--shared
- 安装tensorflow gpu enable python 2.7 版本
- Python27的安装
- linux python27 安装pymongo
- windows下安装python27
- python27 安装opencv2.4.6
- linux python27安装
- Windows64 Python27 XGboost安装
- Python27安装whl文件
- python27安装pil问题
- python27+Sqlmap安装详解
- c++ enable shared from this
- enable-assembler,--enable-static,--enable-shared编译项的研究 .
- enable-assembler,--enable-static,--enable-shared编译项的研究 .
- enable-assembler,--enable-static,--enable-shared编译项的研究 .
- enable-assembler,--enable-static,--enable-shared编译项的研究
- PAT乙级1008. 数组元素循环右移问题 (20)
- <js>jquery实现新闻滚动效果,ie11支持
- svn E175002 DH keypair
- PMP 强化记忆47过程输入输出工具详细
- C++基础之引用与指针的区别与联系、常引用使用时应注意的问题
- 安装多版本python27并开启enable-shared
- 关于transform下的fixed定位(买一送一,结束语是个小彩蛋哦~)
- BME-Stroke-Rehabilitation-Applications
- Android framework 入门1
- RNN用于二值分类
- Android selinux配置和用法
- 小程序swiper组件做轮播图图片高度问题
- elasticsearch 安装及运行
- lua在mac下环境场景搭建