手动执行笔记本失败

时间:2016-04-13 12:34:57

标签: python c++ jupyter-notebook root-framework

我正在使用具有root C ++内核的Jupyter笔记本来创建一些交互式文档。

笔记本电脑通过我的浏览器运行但是当我尝试使用nbconvert以便通过终端执行笔记本电脑时执行失败。 我使用的命令是:

jupyter nbconvert --ExecutePreprocessor.timeout=600 --to notebook --execute ../notebooks/myfile.ipynb

错误是这样的:

    [NbConvertApp] Converting notebook ../notebooks/myfile.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: root
[NbConvertApp] ERROR | Error while converting '../notebooks/myfile.ipynb'
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 335, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 165, in from_filename
    return self.from_notebook_node(nbformat.read(f, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/notebook.py", line 26, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 130, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 302, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 83, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 70, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 112, in preprocess_cell
    raise CellExecutionError(msg)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
sqrt(3.)
------------------

NameError: name 'sqrt' is not defined

我看到错误来自python,即使我的内核是C ++。我应该在哪里看?

修改

在评论中消化后。我现在正在使用这个命令

jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name='root' --to notebook --execute ../notebooks/myfile.ipynb 

但问题仍然存在。首先,它似乎没有识别出kernel_name属性,其次它仍然无法识别sqrt

[NbConvertApp] WARNING | Config option `kernel_name` not recognized by `ExecutePreprocessor`.
[NbConvertApp] Converting notebook ../notebooks/2-ROOT-Basics.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: root
[NbConvertApp] ERROR | Error while converting '../notebooks/2-ROOT-Basics.ipynb'
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 335, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 165, in from_filename
    return self.from_notebook_node(nbformat.read(f, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/notebook.py", line 26, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 130, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 302, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 83, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 70, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/usr/local/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 112, in preprocess_cell
    raise CellExecutionError(msg)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
sqrt(3.)
------------------

NameError: name 'sqrt' is not defined

0 个答案:

没有答案