CentOS 6
Sponsored Link

Python 2.7 インストール2016/07/31

 
CentOS 6 標準の Python のバージョンは 2.6系ですが、2.7系を RPM パッケージでインストールします。
[1] CentOS SCLo Software Collections からインストール可能です。
なお、デフォルトバージョンの 2.6系がインストールされた状態でも、Software Collections パッケージは別パスにインスールされるため、複数バージョンの共存が可能となっています。
# SCLoからインストール

[root@dlp ~]#
yum --enablerepo=centos-sclo-rh -y install python27
[2] Software Collections パッケージは /opt 配下にインストールされます。
環境変数を読み込んで利用するには以下のように実行します。
# 環境変数を読み込む

[root@dlp ~]#
scl enable python27 bash
[root@dlp ~]#
python -V

Python 2.7.8
[root@dlp ~]#
which python

/opt/rh/python27/root/usr/bin/python
[3] ログイン時に自動的に有効にするには以下のように設定します。
[root@dlp ~]#
vi /etc/profile.d/python27.sh
# 以下の内容で新規作成

#!/bin/bash

source /opt/rh/python27/enable
export X_SCLS="`scl enable python27 'echo $X_SCLS'`"
関連コンテンツ