How to use nbconvert - 5 common examples

To help you get started, we’ve selected a few nbconvert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter / nbgrader / nbgrader / preprocessors / View on Github external
from nbconvert.preprocessors import Preprocessor
from traitlets import List, Unicode, Bool

class NbGraderPreprocessor(Preprocessor):

    default_language = Unicode('ipython')
    display_data_priority = List(['text/html', 'application/pdf', 'text/latex', 'image/svg+xml', 'image/png', 'image/jpeg', 'text/plain'])
    enabled = Bool(True, help="Whether to use this preprocessor when running nbgrader").tag(config=True)
github newaetech / chipwhisperer / jupyter / View on Github external
def clear_notebook(path):
    real_path = Path(path)
    body = ""
    with open(real_path, "r", encoding="utf-8") as nbfile:
        nb =, as_version=4)
        co = ClearOutputPreprocessor()
        exporter = NotebookExporter()
        node, resources = co.preprocess(nb, {'metadata': {'path': './'}})
        body, resources = exporter.from_notebook_node(node, resources)
    with open(real_path, "w", encoding="utf-8") as nbfile:
github vatlab / sos / src / sos / jupyter / View on Github external
def __init__(self, config=None, export_all=False, **kwargs):
        self.output_extension = '.sos'
        self.output_mimetype = 'text/x-sos'
        self.export_all = export_all
        Exporter.__init__(self, config, **kwargs)
github bwohlberg / sporco / docs / source / View on Github external
def execute_notebook(npth, dpth, timeout=1800, kernel='python3'):
    Execute the notebook at `npth` using `dpth` as the execution
    directory.  The execution timeout and kernel are `timeout` and
    `kernel` respectively.

    ep = ExecutePreprocessor(timeout=timeout, kernel_name=kernel)
    nb =, as_version=4)
    t0 = timer()
    ep.preprocess(nb, {'metadata': {'path': dpth}})
    t1 = timer()
    with open(npth, 'wt') as f:
        nbformat.write(nb, f)
    return t1 - t0
github ipython / ipython / nbconvert1 / View on Github external
def render_code(self, cell):

        captured_outputs = ['text', 'html', 'svg', 'latex', 'javascript']

        cell = copy.deepcopy(cell)
        cell['input'] = ''

        for output in cell.outputs:
            if output.output_type != 'display_data':
        return nb.ConverterNotebook.render_code(self, cell)


Converting Jupyter Notebooks

Latest version published 13 days ago

Package Health Score

100 / 100
Full package analysis

Popular nbconvert functions

Popular Python code snippets

Find secure code to use in your application or website