[IPython-dev] Using IPython API to create notebook

Robert Alexander roalexan at microsoft.com
Thu Nov 6 13:17:25 EST 2014


Thanks (and apologies for my newness to Python) - the import problems are resolved. BTW, for others, I also stumbled upon this link, http://nbviewer.ipython.org/gist/fperez/9716279,<http://nbviewer.ipython.org/gist/fperez/9716279> which has some good sample code to create and save a new notebook (using the nbformat module that you mentioned).


________________________________
From: ipython-dev-bounces at scipy.org <ipython-dev-bounces at scipy.org> on behalf of Thomas Kluyver <takowl at gmail.com>
Sent: Thursday, November 6, 2014 12:34 PM
To: IPython developers list
Subject: Re: [IPython-dev] Using IPython API to create notebook

Hi Robert

On 6 November 2014 09:26, Robert Alexander <roalexan at microsoft.com<mailto:roalexan at microsoft.com>> wrote:

I'm trying to use the IPython API (see:

http://ipython.org/ipython-doc/2/api/generated/IPython.html.services.notebooks.nbmanager.html#module-IPython.html.services.notebooks.nbmanager) to programmatically create a notebook in IPython 2.3.0, but hitting some problems. Here are the steps that I tried:

The immediate problem is that importing a Python package does not automatically import modules within that. To import that module, you would do something like:

from IPython.html.services.notebooks import nbmanager

However, creating notebooks programmatically is easier with nbformat. Create a notebook using new_notebook():

http://ipython.org/ipython-doc/2/api/generated/IPython.nbformat.v3.nbbase.html#module-IPython.nbformat.v3.nbbase

And save it using write():

http://ipython.org/ipython-doc/2/api/generated/IPython.nbformat.v3.nbbase.html#module-IPython.nbformat.v3.nbbase

Best wishes,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141106/b676e349/attachment.html>


More information about the IPython-dev mailing list