!!!CentOS6にPython2.7をインストール [CentOS][Python] *http://www.petitec.com/2013/04/centos6%E3%81%ABpython2-7%E3%82%92%E5%85%A5%E3%82%8C%E3%82%8B/ *http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/ !!!インストール !!ダウンロード *https://www.python.org/ftp/python/ $ wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 $ wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz !!各種ライブラリインストール *必要に応じ、各種ヘッダファイルを事前にインストールしておく。 *後で必要な場合、インストール後、Python2.7 をリビルドする ::以下のようなエラーとなる >>> import glib Traceback (most recent call last): File "", line 1, in ImportError: No module named glib !gccが入っていない場合、インストール # yum install gcc !bzip2-devel # yum install bzip2-devel !zlib-devel *http://goo.gl/7PLDtV ""zlib-devel がインストールされていないと、後のPyPIのインストールで失敗するため、事前に入れておく # yum install zlib-devel !openssl *http://goo.gl/J2BaUH ""SSLが使えるようにしておかないと、PIPのインストールでエラーになる。>>> import ssl でエラーになる場合、インストールされていない *opensslの場所を確認、/usr 以下に存在 # whereis openssl openssl: /usr/bin/openssl /usr/lib/openssl /usr/share/man/man1/openssl.1ssl.gz ::openssl-devel のインストール # yum install openssl-devel ::Setup.dist の SSL のコメントを外す # cd Python-2.7.5 # cd Modules/ # vi Setup.dist Setup.dist の編集 *上記で確認した、SSL=/usr に編集 # Socket module helper for SSL support; you must comment out the other # socket line above, and possibly edit the SSL variable: # SSL=/usr/local/ssl SSL=/usr _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto !sqlite ""Python をソースからインストールすると sqlite3 とかいろいろモジュールのインポートに失敗する *http://fishrimper.blogspot.jp/2012/12/python-sqlite3.html # yum install -y sqlite-devel.i686 !!python 本体のインストール !Configure $ tar xvf Python-2.7.5.tar.bz2 $ su # cd Python-2.7.5 # ./configure --prefix=/usr/local !make & install ""altinstall を使うこと。make installだと、既存のものと衝突してしまう # make && make altinstall !!確認 */usr/local/bin/python2.7 にコマンドがインストールされる # python2.7 Python 2.7.5 (default, Aug 4 2013, 09:03:22) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> !!!PyPI(Python Package Index) *Pythonの公式のサードパーティソフトウェアリポジトリ *Python WindowsにPIPをインストール !!ダウンロードとインストール # wget https://pypi.python.org/packages/source/d/distribute/distribute-0.6.9.tar.gz # tar xvf distribute-0.6.9.tar.gz # cd distribute-0.6.9 # python2.7 setup.py install !!EasyInstallが使えるようになるので、PIPをインストール *PIP:パッケージのインストールと管理ツール *http://www.pip-installer.org/en/latest/ # easy_install-2.7 pip *https://pypi.python.org/pypi ""2.7.9、または3.4 からは、pip は同梱されている。pipをセキュアにインストールするには、以下からget-pip.py を入手し、実行 *https://bootstrap.pypa.io/get-pip.py # python2.7 get-pip.py !!Django *Django インストール 1.5.1 !!Python IDEをCentOSで利用する *Python IDEをCentOSで利用する