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

Thomas Kluyver takowl at gmail.com
Wed Mar 18 13:51:41 EDT 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150318/b9cccc42/attachment.html>


More information about the IPython-dev mailing list