This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: nbconvert.nbconvertapp

NbConvert is a utility for conversion of .ipynb files.

Command-line interface for the NbConvert conversion utility.

2 Classes

class IPython.nbconvert.nbconvertapp.DottedOrNone(default_value=<IPython.utils.traitlets.NoDefaultSpecified object>, allow_none=None, **metadata)

Bases: IPython.utils.traitlets.DottedObjectName

A string holding a valid dotted object name in Python, such as A.b3._c Also allows for None type.

class IPython.nbconvert.nbconvertapp.NbConvertApp(**kwargs)

Bases: IPython.core.application.BaseIPythonApplication

Application used to convert from notebook file type (*.ipynb)


Convert the notebooks in the self.notebook traitlet


Convert a single notebook. Performs the following steps:

  1. Initialize notebook resources
  2. Export the notebook to a particular format
  3. Write the exported notebook to file
  4. (Maybe) postprocess the written file
export_single_notebook(notebook_filename, resources)

Step 2: Export the notebook

Exports the notebook to a particular format according to the specified exporter. This function returns the output and (possibly modified) resources from the exporter.


Construct the list of notebooks. If notebooks are passed on the command-line, they override notebooks specified in config files. Glob each notebook to replace notebook patterns with filenames.


Initialize the postprocessor (which is stateless)


Step 1: Initialize resources

This intializes the resources dictionary for a single notebook. This method should return the resources dictionary, and MUST include the following keys:

  • profile_dir: the location of the profile directory
  • unique_key: the notebook name
  • output_files_dir: a directory where output files (not including the notebook itself) should be saved

Add the cwd to the sys.path ($PYTHONPATH)


Initialize the writer (which is stateless)


Step 4: Postprocess the notebook

This postprocesses the notebook after it has been written, taking as an argument the results of writing the notebook to file. This only actually does anything if a postprocessor has actually been specified.


Ran after initialization completed

write_single_notebook(output, resources)

Step 3: Write the notebook to file

This writes output from the exporter to file using the specified writer. It returns the results from the writer.