目次へ
ノートブックを使う環境からすると Mathematica, Sage と IPython が似ているので興味を持っていた。最近、ネットワークて検索して IPython notebook と Sage notebook の違いについて書いてあるすばらしい記事を見つけました。
Fernando Perez, The IPython notebook: a historical retrospective
その後、Ipython からsage を使う設定方法を見つけた。
- Sébastien Labbé, Using sage in the new ipython notebook
- Sage and IPython
- IPython, Sage, Dependencies, Anaconda, and Packages Integrating?
Mac OS X Mavericks での設定( Ubuntu 12.04 でも同じ設定 )
コンピュータ環境は次です。
- Mac OS X Mavericks 10.9.2
- Sage Version 6.1.1, Release Date: 2014-02-04
$./sage -sh
(sage-sh) $ easy_install-2.7 tornado
./sage -i zeromq
./sage -i pyzmq
この段階で ipython-0.12 がインストールされている。
ipython を次で起動し、最初のセルで from sage.all import *
を実行することにより Sage の関数を使うことができる。
./sage -ipython notebook
IPython ノートブックを示す。このノートブックは起動したディレクトリ に保存される。
2行目の frpm sage.all import *
を %load_ext sage
に変更する必要があります。(July 2015 )
まとめと今後
- 上記のWeb に書いてある方法で IPython からSage を使うことができた。すばらしい環境と思います。
- インストールされる IPython のバージョンは 0.12である。次期 Sage 6.2 では ipython-1.2.1 が組み込まれているとの情報を得た。
- 使い込んでチェックを行うのが今後の課題です。
Sage 6.2 から IPython 1.2.1 notebook を利用する[成功] ( Ubuntu 14.04, Mac OS X 10.9 ) (2014/05/28)]
久しぶりに調べたところバージョンが上がっていた。
- Sage 6.2 <---- 6.1
- IPython 2.1 <---- 1.21
Sage のインストールについては Ubuntu フォーラムの投稿記事が参考になる。
Sage で ipython が使えるか次で確認できる。
$ sage -ipython
Python 2.7.5 (default, May 6 2014, 17:44:23)
IPython 1.2.1 -- An enhanced Interactive Python.
7月2014 現在、Sage がサポートしている IPython のバージョンは 1.2.1 なのでこれをインストールする。
IPython notebook を使えるようにするための設定
設定 1.
$ sage -i zeromq
$ sage -i pyzmq
設定 2.
Installing IPython のページの最後にあるdownload archive から ipython-1.2.1.tar.gz をダウンロードし解凍する。
$ cd ipython-1.2.1
$ sage -sh
(sage-sh) $ python setup.py install
(sage-sh) $ exit
次で ipython 1.2.1 のノートブックが開かれる。
$ sage -ipython notebook
ノートブックの最初のセルに from sage.all import *
を入力すれば sage が使える環境になります。
入力行の script を出力する場合は次が便利です。
$ sage -ipython notebook --script