NETWORK ENGINEER BLOG

Tips and Reviews for Engineers

CentOS6.3 に Python2.7.3 をインストール

インストール手順

zlib のヘッダファイル・ライブラリのインストール

※インストールしていないとエラー*1が発生し、Distribute のインストールに失敗する場合があります。

[root@hostname ~]# yum install zlib-devel
OpenSSL development のインストール

※インストールしていないとエラー*2が発生し、pip のインストールに失敗する場合があります。

[root@hostname ~]# yum install openssl-devel
Python2.7.3 のインストール

Python2.7.3 をダウンロードして解凍

[root@hostname ~]# wget --no-check-certificate http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
[root@hostname ~]# tar zxvf Python-2.7.3.tgz

コンパイルとインストール

[root@hostname ~]# cd Python-2.7.3
[root@hostname ~]# ./configure --prefix=/usr/local
[root@hostname ~]# make
[root@hostname ~]# make altinstall
Distribute のインストール

Distribute をダウンロードして解凍

[root@hostname ~]# wget --no-check-certificate http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz
[root@hostname ~]# tar zxvf distribute-0.6.27.tar.gz

Distribute をインストール

[root@hostname ~]# cd distribute-0.6.27
[root@hostname ~]# python2.7 setup.py install
pip のインストール

easy_install-2.7 で pip をインストール

[root@hostname ~]# easy_install-2.7 pip
Paramiko のインストール

pip コマンドで paramiko をインストール

[root@hostname ~]# pip install paramiko

paramiko が読み込める事を確認(SSH 関連のみ抜粋)

[root@hostname ~]# python2.7
Python 2.7.3 (default, Apr  6 2014, 00:41:52)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
>>> filter(lambda s: s.startswith("SSH"), dir(paramiko))
['SSHClient', 'SSHConfig', 'SSHException']

モジュールの一覧を確認(抜粋)

[root@hostname ~]#  python -c "help('modules')"
Please wait a moment while I gather a list of all available modules...
BaseHTTPServer      calendar            imaplib             rlcompleter
Bastion             cgi                 imghdr              robotparser
CDROM               cgitb               imp                 rpm
CGIHTTPServer       chunk               imputil             rpmUtils
CORBA               cmath               iniparse            runpy
ConfigParser        cmd                 inspect             scanext
Cookie              code                invest              scdate
DLFCN               codecs              io                  sched
<...snip...>
Exscript のインストール

pip コマンドで Exscript をインストール

[root@hostname ~]# pip install https://github.com/knipknap/exscript/tarball/master

Exscript のバージョンを確認

[root@hostname ~]# exscript --version
DEVELOPMENT

以上

*1:RuntimeError: Compression requires the (missing) zlib module

*2:error: Could not find suitable distribution for Requirement.parse('pip'