Friday, March 30, 2012

Up And Running With ipython

I'll probably quickly go back to using CodeRunner unless I find ipython offers something unique. Python itself is so cool because it is used to solve so many problems, like natural language processing. See the Natural Language Processing with Python book at http://www.nltk.org/book. ipython is installed throughout the use of easy_install.

I have to sudo the install commands because the makers of these libraries seem to think Python is installed in ~/Library but in fact it is in /Library, probably due to a mistake on my part. The mistake necessitated a little editing in the pydistutils.cfg file to remove the tilde.

The file ~/.pydistutils.cfg
[install]
install_lib = /Library/Python/$py_version_short/site-packages
install_scripts = ~/bin
The install commands I used:
[~] sudo easy_install ipython[zmq,test]

[~] cd /Library/Python/2.7/site-packages/

[site-packages] sudo easy_install sympy

[site-packages] cd /System/Library/Frameworks/Python.framework/Versions/2.7/extras

[extras] sudo easy_install readline
It seems like I last did matrix functions in the 7th grade so let's try that.
In [1]: %logstart

In [2]: from sympy import *

In [3]: from sympy.matrices import Matrix

In [6]: B = Matrix(2, 3, [1, 2, 3, 4, 5, 6])

In [7]: B
Out[7]: 
[1, 2, 3]
[4, 5, 6]

In [12]: C = Matrix(3, 2, [1, 2, 3, 4, 5, 6])

In [13]: C
Out[13]: 
[1, 2]
[3, 4]
[5, 6]

In [14]: B * C
Out[14]: 
[22, 28]
[49, 64]
I'll just have to presume this is right. Thanks ipython!