f.c.v.systemのブログ -9ページ目

f.c.v.systemのブログ

IT関連の記事を書いていきます

CentOS 6.5にPython2.7.6をインストールした時のメモ

元々CentOSに2.6.6がインストールされているみたいなので、
それは残したままインストールを実施する。

pythonのインストール

□参考にしたサイト
How to install Python 2.7 and 3.3 on CentOS 6
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/

□手順

0. 現在のバージョン確認

$ python -V
Python 2.6.6

1. 必要なパッケージ類をyumでインストール
$ yum groupinstall "Development Tools"
$ yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

2. Pythonのソースをwgetにて取得する。

$ yum install wget.x86_64
$ mkdir /opt/python/
$ cd /opt/python
$ wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz

3. 資材を解凍して、インストール
$ tar xvfz Python-2.7.6.tgz
$ cd Python-2.7.6
$ ./configure
$ make
$ make altinstall

4. インストールの後の確認。

$ ls /usr/local/bin/ | grep python
python2.7
python2.7-config

Pythonコマンドで実施出来るように、シンボリックリンクを作成

$ ln -s python2.7 python
$ ls /usr/local/bin/ | grep python
python -> python2.7
python2.7
python2.7-config

$ python -V
Python 2.6.6

あれ、まだ変わっていない。

$ which python
/usr/local/bin/python

$ /usr/local/bin/python -V
Python 2.7.6

$ python -V
Python 2.6.6

読み込み先が間違っているのかな?

$ which -a python
/usr/local/bin/python
/usr/bin/python

$ /usr/bin/python -V
Python 2.6.6

こっちが読み込まれているようだ。なんでだろうと考えるのと試すこと3分。
ログインセッションがそのままになっていることに気づいた。
そのためログインし直し。

$ python -V
Python 2.7.6

これでインストール完了!