The first step is to set up the IPython notebook so that it can be most useful. This includes creating a profile, installing some extensions and making sure all useful tools are updated. This notebook should only need to be run once.
A profile is the location where Ipython stores all of your settings. To create a profile just run the following:
In [2]:
# Initialize profile
import IPython
import os.path as path
# Create a profile
profile, = !ipython locate profile
if not profile:
!ipython profile create
print 'Your profile is located at:\t', profile
# Get local paths for later use
ip = IPython.get_ipython()
nbext = path.join(ip.ipython_dir, 'nbextensions')
custom = path.join(profile, 'static/custom/custom.js')
print "Extension files should be placed in: ", nbext
print "Extension settings should be added to: ", custom
There are many IPython and IPython notebook extensions available.
Github List of IPython extensions - https://github.com/ipython/ipython/wiki/Extensions-Index
Github List of IPython notebook extensions - https://github.com/ipython-contrib/IPython-notebook-extensions
Lets go ahead and install 4 notebook extensions that I find very useful. To install an extension you first download the extension and place it in:
In [6]:
print nbext
Then need to edit the file:
In [4]:
print custom
and add an IPython load statment:
`IPython.load_extensions('name_of_extension');`
IPython notebook does not have spell check by default. There are a variety of spell check extensions that have been created. None of these extensions are perfect, but the 'Spell Checking' extension from the Calico project (http://calicoproject.org/ICalico) does all that I need. Here is a youtube video describing the extension:
In [56]:
from IPython.display import YouTubeVideo
YouTubeVideo('o4xCp3b4oCw')
Out[56]:
The following command will download and copy the extension to the appropriate location.
In [2]:
!ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip --user
There are three additional extensions from the IPython notebook extension project (https://github.com/ipython-contrib/IPython-notebook-extensions/wiki). I have only looked at some of the 'usability' extensions.
If you are on unix then the following commands will download and place the exentsions in the correct location. If you are on OSX or Windows you need to download:
https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip
Extract it and copy the 'usability' folder into:
In [7]:
print nbext
In [27]:
%%bash -c "mydir=$nbext bash"
cd $HOME/Downloads
wget https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip --quiet
unzip -q master.zip
mv ./IPython-notebook-extensions-master/usability $mydir/
In [8]:
print custom
The following command will install the 4 extensions.
In [9]:
settings="""require(["base/js/events"], function (events) {
events.on("app_initialized.NotebookApp", function () {
IPython.load_extensions('calico-spell-check');
IPython.load_extensions('usability/runtools/main');
IPython.load_extensions('usability/codefolding/main');
IPython.load_extensions('usability/python-markdown/main');
});
});
"""
with open(custom, 'w') as OUT:
OUT.write(settings)
In [ ]: