我想用一个较旧的Python(2.7.3)与旧的CentOS。LD_LIBRARY_PATH与sudo python
我有一个配方安装Python到一个非标准的位置:
./configure --prefix=#{install_path} --with-threads --enable-shared --with-zlib=/usr/include
make
make install
我设置了PATH
和LD_LIBRARY_PATH
变量找到bin/python
和使用/etc/profile.d/
的.so
文件。这似乎主要是工作。
对于非root用户,我得到正确的Python:
[[email protected] ~]$ python
Python 2.7.3 (default, Dec 24 2012, 15:18:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
用root用户,我得到正确的Python:
[[email protected] ~]$ sudo su
[[email protected] vagrant]# python
Python 2.7.3 (default, Dec 24 2012, 15:18:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
然而,$LD_LIBRARY_PATH
黑客似乎是
[[email protected] ~]$ sudo python
python: error while loading shared libraries: libpython2.7.so.1.0:
cannot open shared object file: No such file or directory
即使变量看的权利:使用sudo的时候有点wonked
[[email protected] ~]$ sudo which python
/opt/Python-2.7.3/bin/python
添加Defaults env_keep += "LD_LIBRARY_PATH"
到/etc/sudoers
不起作用。
sudo -i python
确实有效。 sudo -E python
不起作用。
我很好奇我能做些什么来让sudo
拿起正确的Python而没有-i
?
相关:
https://stackoverflow.com/questions/12593336/odd-path-behaviour-on-centos-python