Installing iPython Notebook on a Mac OS X Mountain Lion

Installing iPython Notebook on a Mac OS X Moutain Lion 10.8.1 for Development and Testing

The “Quickstart” is anything but that leaving off details like the recomended dependencies are basically required for a functional notebook. Here is the sequence that worked for me.

[apps]$ mkvirtualenv ipythonvm –distribute
[apps]$ workon ipythonvm

at this point pip freeze shows

[apps]$ pip freeze
distribute==0.6.28
wsgiref==0.1.2

next up the big instAll

[apps]$ easy_install ipython[zmq,qtconsole,notebook,test]

the instructions suggest running iptest. Don’t bother yet. It will fail the tests without more dependencies like “nose’ installed. Keep on. Also note the “easy_install” in front of readline is specific to set the sequence to pass the tests. Not sure why. No time to question today and I’m in a VM so it can’t do much harm. Proceed with.

[apps]$ pip install nose
[apps]$ easy_install readline
[apps]$ easy_install pexpect
[apps]$ easy_install ipython[zmq]

At this point checking packages shows

(ipythonvm)LOCAL:~/dropbox/code/apps
[apps]$ pip freeze
distribute==0.6.28
ipython==0.13
nose==1.2.1
pexpect==2.4
pyzmq==2.2.0.1
wsgiref==0.1.2

but

[apps]$ ipython qtconsole

fails. Keep trying.

pip install Tornado

Tornado works, but still errors on ZeroMQ. It comes down to this. We need ZeroMQ and PyZMQ. PyZMQ is installed (see pip freeze lista bove) but is missing the dependencie ZeroMQ doesn’t work with pip or easy_install as far as I can tell. Now we go old school. I also didn’t read the docs and was a bit tired so rather than specifying to intsall in the virtualenv I accepted the defaults and installed it in /usr/local/bin globally.

for ZeroMQ, I downloaded the Mac latest stable release from this page:
http://download.zeromq.org/

On 9/15/2012 I downloaded this one and extracted it:
zeromq-2.2.0.tar.gz 14-Apr-2012 09:53 1.8M

Unpack the .tar.gz source archive and cd into that directory. Remember I installed globally for this one package after the battle so first I had to “deactivate” in the virtual environment I was in (iphythonvm for me). Then change into that directory someplace you have “write” rights. For me I copied it from downloads to “code/contribs” which is where I put random stuff I haven’t modified but may or may not be using. Thus the next command was:

cd zeromq-2.2.0/

Run ./configure, followed by make.

But remember, outside of a VM we are back to sudo so this looks like:

sudo ./configure
password:
sudo make
sudo make install

switch back to my VM

[apps]$ workon ipythonvm

the environment now looks like this:

(ipythonvm)LOCAL:~/dropbox/code/apps
[apps]$ pip freeze
distribute==0.6.28
ipython==0.13
nose==1.2.1
pexpect==2.4
pyzmq==2.2.0.1
wsgiref==0.1.2

now we try again.

[apps]$ ipython notebook

Success! Now let’s go get somethign to look at. I created a folder in my apps folder to put the downloads and grabbed a git repository from blogger Titus of Living in an Ivory Basement http://ivory.idyll.org/blog/teaching-with-ipynb.html

mkdir iPythonNotebooks
cd iPythonNotebooks
git clone git://github.com/ngs-docs/ngs-notebooks.git

Now we test it again:

[iPythonNotebooks]$ ipython notebook
[NotebookApp] Using existing profile dir: u’/Users/eschipul/.ipython/profile_default’
[NotebookApp] Serving notebooks from /Users/eschipul/Dropbox/Code/apps/iPythonNotebooks
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/

I then imported the ngs-10-blast notebook. There are codeblocks in the notebook, so for a proof of concept I just picked one that imported “blast” knowing I had not imported it. Inside of Chrome, inside of the notebook, I can click on a codeblock that begins:

import csv
import blastparser

# open the output file for reading
fp = open(‘out.txt’)

and then I select “cell run” and it runs it as if I was in Eclipse. Properly giving an error of

—————————————————————————
ImportError Traceback (most recent call last)
in ()
1 import csv
—-> 2 import blastparser
3
4 # open the output file for reading
5 fp = open(‘out.txt’)

ImportError: No module named blastparser

That is huge. Think about it. Running code inline in the middle of a web page with a compiler and debugging. Not javascript by Python in a sandbox that can import modules and do everything else you would do with idyl. And saved in JSON based notebooks that can be shared and used for testing. It sort of blows your mind.

I’m not suggesting this is a replacement for a good training video. But it is a great addition to the educators arsenal of tools for online learning in richer environments with greater interactivity. I’m impressed to say the least.

Other randome take-aways. I did not know about the pexpect package and it is pretty compelling if you work at a company. It removes the need for the C libraries for builds which means that not everyone needs to install xCode if they have to /configure, make, make install, etc.

Thus I recommend you take a look at what pexpect can do as it was new to me. Pretty cool actually.
http://www.noah.org/wiki/Pexpect#Description_of_Pexpect

Geometry and the Munduruk̼ РAnthropology and Geometric Understanding

A very timely post in Slashdot on geometry and visualization today.  It relates to an anthropology study on the human interpretation of visual information through geometry.  It is timely because at the end of January Edward Tufte is presenting in Houston this month and I hope to attend! 

More on the article on geometry and the Mundurukú people.

Munduruku_geometryWe’re hard-wired for geometry (By Daniel B. Kane)
Tests with Amazon villagers hint at innate geometrical sense

WASHINGTON – Even if you never learned the difference between a triangle, a rectangle and a trapezoid, and you never used a ruler, a compass or a map, you would still do well on some basic geometry tests, according to a new study.

Using a series of nonverbal tests, scientists claim to have uncovered core knowledge of geometry in villagers from a remote region of the Amazon who have little schooling or experience with maps and speak a language without the mathematical language of geometry.

and

the authors of the new study conclude that they have uncovered evidence for a basic understanding of geometry among people without much formal education. Future research may clarify if humans are born with these intuitions or if we acquire them early in life.

We spend a great deal of energy and time with Tendenci reporting trying to create visualization of Munduruku_rightangle the actions taking place on the site to communicate back to the organizations.  Beyond basic network diagrams which are still best assembled by hand, it is a frustrating process.  Not to create the chart, but to create a chart that is easily comprehended. And it is far more complex than visualization of explicit social network connections

I like the visualization discussion at the bottom of this post regarding implicit networks as opposed to explicit networks.  That is a post for another day.