Can’t update IPython

Well, been trying to get the IPython “nbconvert” command to run, to convert some IPython notebooks to html and/or slides. However, when I type this in Terminal:

samb@Mephisto:~$ ipython nbconvert

I get this output:

[TerminalIPythonApp] File not found: u'nbconvert'

This is weird because “nbconvert” is supposed to be built into IPython. Looking around the web, it seems as though “nbconvert” is only built in to IPython versions >1.0. Let’s check my version of IPython:

samb@Mephisto:~$ ipython --version
0.13.2

So, that explains it. I’m running v0.13.2. This is mildly irritating, as I just installed IPython a week ago. In fact, the latest stable version listed on the IPtyhon install page is 1.2.1 from February.

Selection_011

 

However, I can’t get IPython to update. When I try to use “apt-get”, this is what happens:

samb@Mephisto:~$ sudo apt-get install ipython-notebook
Reading package lists... Done
Building dependency tree
Reading state information... Done
ipython-notebook is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Sooooooo, now what?

I’m going to try to remove IPython via the Ubuntu Software Center.

OK, done.  To be safe, will reboot computer and then verify IPython removal has been completed.

After restarting, typing “ipython notebook” in to Terminal indicates that it is not installed and suggests I can get, and install, IPython by entering “sudo apt-get install ipython”.  However, I’m going to follow the instructions on the IPtyhon install page, which instructs the user to enter: sudo apt-get install ipython-notebook

This is how things turned out:

samb@Mephisto: ~_014

See that?  “Setting up ipython-notebook (0.13.2-2)…”  That’s the same version I had previously!  So, I guess I need to hunt down the more recent version.  At the bottom of the IPtyhon install page there is a link to the IPython Downloads Archive and this is what’s in it:

Selection_015

Lo and behold, the current version, which is MANY versions removed from the version that “apt-get” is retrieving.  Clicking on that link brings me to a page with a “tarball” (a file that ends with “.tar.gz”) and a ZIP file.

Downloaded the tarball http://archive.ipython.org/release/1.2.1/ipython-1.2.1.tar.gz by clicking on the link (I should learn how to do that in the command line).

Un-tarred and un-gzipped the file in Terminal:

samb@Mephisto:~/Downloads$ tar -xzf ipython-1.2.1.tar.gz

I then moved (using the GUI) the un-tarred and un-gzipped ipython-1.2.1 folder to my /home/samb directory and followed the installation directions for installing IPython from source.

The Terminal showed a bunch of stuff. Let’s see if using “nbconvert” does anything.

Result? Typing “ipython nbconvert” spits out a whole bunch of stuff; which is great!

I’ll launch IPython and see if it still sees my configuration file from the initial install/configuration last week.

Didn’t work! Launched IPython (ipython notebook) and this is what I got:

ImportError: No module named jinja2

Looking back at the installing IPython from source page, it doesn’t indicate that required dependencies are not installed by default. Maybe that’s always the case when installing packages from source when using Linux? I have no idea, but it would certainly be nice if the IPython instuctions indicated that, particularly since using “apt-get” doesn’t retrieve the most recent IPython build, thus potentially requiring people to download the source file.

Now that we’ve encountered this problem, I’m going to try to install IPython using “pip”. However, when I try running “pip” from Terminal, I’m informed that “pip” is not installed on the system. So, we’ll get it:

samb@Mephisto:~$ sudo apt-get install python-pip

Now, let’s run (as shown on the IPtyhon install page) :

samb@Mephisto:~$ pip install ipython[all]
Requirement already satisfied (use --upgrade to upgrade): ipython[all] in /usr/local/lib/python2.7/dist-packages
Installing extra requirements: 'all'
Cleaning up...
samb@Mephisto:~$ ipython --version
1.2.1

Not thrilled by the “Requirement already satisfied” output, since I uninstalled the last IPython (used the Ubuntu Software Center Package Manager). And, guess what. The notebook won’t launch and still spits out the error message about no jinja2 module. I’ll try restarting the computer and see if that helps.

And…

It did not help. I’m going to just delete the python2.7 directory found in /usr/local/lib, since that’s where all the IPython stuff seems to live. Deleted the directory:

samb@Mephisto:~$ sudo rm -rv /usr/local/lib/python2.7

rm = remove
-rv = recursively (r), verbose (v) to see all the files as they get deleted

Tried using “pip” again:

pip install ipython

It downloaded the ipython1.2.1 tarball, extracted stuff and then…

couldn’t write to the /usr/local/lib directory due to lack of permissions.

So, I re-ran the command with “sudo” and everything seems to have installed properly and completely. Trying to launch IPython notebook yields…

THE SAME JINJA2 module message!!!

Ahhhhh. Just realized I didn’t run:

sudo pip install ipython[all]

Totally forgot the “[all]”. Let’s try again.

Removed the python2.7 directory, as before. Ran sudo pip install ipython[all]. Ha! Well look at that! Here’s the end portion of the output from the that:

changing mode of /usr/local/bin/rstpep2html.py to 755
changing mode of /usr/local/bin/rst2latex.py to 755
changing mode of /usr/local/bin/rst2html.py to 755
Successfully installed ipython Sphinx pygments jinja2 nose docutils
Cleaning up...

Now, try to launch IPython and… Success!! I have finally managed to upgrade IPython! Not only that, but it has retained my previous configuration set up for the default notebook location. And, finally, test out if “nbconvert” is present. Yep! It’s there (just typed: ipython nbconvert)!

Here’s the quick summary of what I ended up having to do:

1. Had to delete the Python2.7 folder (located at /usr/local/bin).

2. Had to install “pip” (sudo apt-get install python-pip)

3. Used “pip” to retrieve and install most current version of IPython (sudo pip install ipython[all]

 

 

 

Leave a Comment