The newest release of IPython introduced a new exciting feature – the web notebook. A so called "notebook server" can serve notebooks over the web. We can now start a notebook server and have a web-based IPython environment. This environment has most of the features in the regular IPython environment. The new features include the following:
Before we start, we should make sure that all the required software is installed. There is a dependency on tornado
and zmq
. See the Installing IPython recipe in this chapter for more information.
$ ipython notebook [NotebookApp] Using existing profile dir: u'/Users/ivanidris/.ipython/profile_default' [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888 [NotebookApp] Use Control-C to stop this server and shut down all kernels.
As you can see, we are using the default
profile. A server started on the local machine at port 8888. We will learn how to configure these settings later on in this chapter. The notebook is opened in your default browser; this is configurable as well:
IPython lists all the notebooks in the directory where you started the notebook. In this example no notebooks were found. The server can be stopped with Ctrl + C.
$ ipython notebook --pylab
This loads the Scipy, NumPy, and Matplotlib modules.
$ ipython notebook --pylab inline
arange
function. Type the command in the following screenshot, and press Enter:Next, enter the following command and press Enter. You will see the output as shown in Out [2] in the following screenshot:
sinc
function to the array and plot the result, as shown in the following screenshot:The inline option lets you display inline Matplotlib plots. When combined with the pylab mode, you don't need to import the NumPy, SciPy, and Matplotlib packages.