古いCentOSで新しいPython(2.7.3)を使用しようとしています。
Pythonを非標準の場所にインストールするレシピがあります:
./configure --prefix=#{install_path} --with-threads --enable-shared --with-zlib=/usr/include
make
make install
を使用して、検索する変数PATH
とファイルを設定します。これはほとんど機能しているようです。LD_LIBRARY_PATH
bin/python
.so
/etc/profile.d/
root以外のユーザーの場合、適切なPythonを取得します。
[vagrant@localhost ~]$ 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を取得できます。
[vagrant@localhost ~]$ sudo su
[root@localhost 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
sudoを使用すると、ハックが少し不安定になるようです。
[vagrant@localhost ~]$ sudo python
python: error while loading shared libraries: libpython2.7.so.1.0:
cannot open shared object file: No such file or directory
変数は正しく見えますが、次のようになります。
[vagrant@localhost ~]$ 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