windowsでipython使う時はpyreadline必要
WindowsでPython使うとき、多くはバイナリーインストーラを使うと思うが、その時同時にインストールされるPython shell(IDLE)はよりも、便利なものがIPython。
IpythonがPyhon shellよりイイ点は、
・コマンドの補完ができること。(モジュール内部の補完も、ファイル名の補完も効く)
・OSのコマンド(コマンドプロンプトで実行できるコマンド)がそのまま使えること。(cd, pwd, ls とか)
その動作確認メモ
http://ipython.org/download.html
からipythonのインストーラとってくる。ここにも書いてあるが、補完機能はreadline ライブラリを使っている。これを入れないと、ipythonのコード補完が効かない。ipython起動時に警告だしてくる。
WARNING: Readline services not available on this platform. WARNING: Proper color support under MS Windows requires the pyreadline library. You can find it at: http://ipython.scipy.org/moin/PyReadline/Intro Gary's readline needs the ctypes module, from: http://starship.python.net/crew/theller/ctypes (Note that ctypes is already part of Python versions 2.5 and newer). Defaulting color scheme to 'NoColor' Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.10.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. Welcome to pylab, a matplotlib-based Python environment. For more information, type 'help(pylab)'. In [1]:
こんなかんじに。
pyreadline はwindows用のバイナリーインストーラがある。ここから取れる。
https://launchpad.net/pyreadline/+download
今しがたは、
pyreadline-1.7.win32.exe
pyreadline-1.6.2.win32.exe
あたりが最新になっている。
この2つを入れると、補完が効くようになる。ディレクトリ操作もできるし、ファイル名の補完、モジュールの補間もできるので手放せないかんじ。
ipythonがインストールされる C:\Python26\Scripts を環境変数PATHにいれて、cmd.exe からipython で起動する。
それから、場合によっては、winpy32も使うと、WindowsならではのCOMも操作できるようになる。せっかくWindows上でPython使うなら、COMも操作できたほうがいいことあるかも、ということでメモしておく。
http://starship.python.net/crew/mhammond/win32/