[IPython-dev] running/getting output into a new programmatically-generated notebook

Ana Nelson ana at ananelson.com
Wed Mar 18 14:13:42 EDT 2015


It wanted a resources argument, an empty dict seems to work.

ExecutePreprocessor().preprocess(nb, {})




On Wed, Mar 18, 2015 at 10:51 AM, Thomas Kluyver <takowl at gmail.com> wrote:

> On 18 March 2015 at 10:15, Ana Nelson <ana at ananelson.com> wrote:
>
>> Currently calling it like this:
>>
>>         subprocess.check_output([
>>             'ipython',
>>             'nbconvert',
>>             '--execute',
>>             '--to', 'notebook',
>>             '--output', nbPath,
>>             nbPath
>>             ])
>>
>
> For the record, if you need to make it more efficient, it should be fairly
> simple to do the same thing in-process, rather than running a separate
> IPython process to do it. Something like:
>
> nb = nbformat.read(nbPath, as_version=4)
> ExecutePreprocessor().preprocess(nb)
> nbformat.write(nb, nbPath)
>
> (Untested)
>
> > By the way, I have just noticed that ipython3 creates v3 notebooks,
> while ipython2 creates v4. Is this by accident?
>
> How did you get that? IPython 3 should create v4 notebooks, and IPython 2
> should create v3 notebooks.
>
> Thomas
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150318/06b7f166/attachment.html>


More information about the IPython-dev mailing list