Pythonでプログラム書いている人のwiki

Pythonのインストール

今時のLinuxディストリビューションではデフォルトで入っていることが多いです。

参考までに、当方は、LinuxMint14を使用しております。
$uname -a
Linux oneshotlife 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:32:08 UTC 2012 i686 i686 i686 GNU/Linux

Pythonがインストールされているかどうかの確認

$which python
/usr/bin/python
whichコマンドでパスが返却されたら、インストールされているということです。

IDLEがインストールされているかどうかの確認

ついでに,PythonのIDE(統合開発環境)のIDLEがインストールされているかどうかの確認もしてみます。
$which idle
/usr/bin/idle
whichコマンドでパスが返却されたら、インストールされているということです。

Pythonのバージョン確認

$python -V
Python 2.7.3

easy_installのインストール

easy_installとは、パッケージ管理ツールのことです。依存関係のあるモジュールなどをインストールする際に、良い具合にインストールしてくれるので重宝します。
ez_setup.pyのDL
easy_install自体は、Python付属のツールではないため、ファイルを取得する必要があります。

wgetコマンドでDLします。DLするディレクトリは、どこでも問題ありません。セットアップ用のファイルが、Pythonのパスに併せて設定してくれるので、難しいことは考えず、適当なディレクトリにファイルをDLして下さい。

$pwd
/home/tom/Downloads
$ls
$pwd
/home/tom/Downloads
$wget http://peak.telecommunity.com/dist/ez_setup.py
--2013-04-07 22:25:12--  http://peak.telecommunity.com/dist/ez_setup.py
Resolving peak.telecommunity.com (peak.telecommunity.com)... 209.190.5.234
Connecting to peak.telecommunity.com (peak.telecommunity.com)|209.190.5.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10240 (10K) [text/plain]
Saving to: `ez_setup.py'

100%[======================================>] 10,240      6.09K/s   in 1.6s    

2013-04-07 22:25:15 (6.09 KB/s) - `ez_setup.py' saved [10240/10240]
ez_setup.pyの実行
easy_installをインストールするには、上記でDLしたez_setup.pyを実行します。

実行権限を見てみるとわかりますが、xつまり実行の権限は付いていません。なので、./ez_setup.pyとやってもダメです。拡張子が.pyのファイルはPythonのファイルです。Pythonのファイルを実行するには、pythonコマンドを使います。
$ll ez_setup.py 
-rw-r--r-- 1 tom tom 10240  1月 21  2011 ez_setup.py
$python ez_setup.py 
Setuptools version 0.6c11 or greater has been installed.
(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)
私の環境では、既にインストールされていたため、その旨のメッセージが出力されました。
easy_installの再インストール、ヴァージョンアップ
easy_installの再インストール、ヴァージョンアップは以下に示すコマンドで行えます。
ファイルの書き込みにスーパーユーザー権限が必要なものがあるため、コマンドの最初にはsudoコマンドが必要です。
$sudo python ez_setup.py -U setuptools
Searching for distribute
Reading http://pypi.python.org/simple/distribute/
Reading http://packages.python.org/distribute
Best match: distribute 0.6.36
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz#md5=a923385de72dcdca68cd4ac2b9dc1148
Processing distribute-0.6.36.tar.gz
Writing /tmp/easy_install-Rx12Db/distribute-0.6.36/setup.cfg
Running distribute-0.6.36/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Rx12Db/distribute-0.6.36/egg-dist-tmp-XemwZS
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /usr/local/lib/python2.7/dist-packages
Non-egg installation
Moving elements out of the way...
Already patched.
/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info already patched.
After install bootstrap.
/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info already exists
Removing distribute 0.6.34 from easy-install.pth file
Adding distribute 0.6.36 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/distribute-0.6.36-py2.7.egg
Processing dependencies for distribute
Finished processing dependencies for distribute
easy_installのヴァージョン確認
$easy_install --version
distribute 0.6.36

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

メンバーのみ編集できます

メンバー募集!