3

我跑步有困难jupyter nbconvert

它总是显示以下错误跟踪(即使是带有几个香草电池的笔记本)

Traceback (most recent call last):
  File "/home/miguel/.virtualenvs/ipython/bin/jupyter-nbconvert", line 11, in <module>
    sys.exit(main())
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/traitlets/config/application.py", line 596, in launch_instance
    app.start()
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 293, in start
    self.convert_notebooks()
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 447, in convert_notebooks
    self.exporter = cls(config=self.config)
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/exporters/templateexporter.py", line 151, in __init__
    super(TemplateExporter, self).__init__(config=config, **kw)
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 101, in __init__
    self._init_preprocessors()
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 250, in _init_preprocessors
    self.register_preprocessor(preprocessor, enabled=True)
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 211, in register_preprocessor
    preprocessor_cls = import_item(preprocessor)
  File "/home/miguel/.virtualenvs/ipython/local/lib/python2.7/site-packages/ipython_genutils/importstring.py", line 31, in import_item
    module = __import__(package, fromlist=[obj])
TypeError: Item in ``from list'' not a string

它可能与我最近安装的 nbextensions 有关,因为几天前该jupyter nbconvert命令曾经完美运行。

今天,我在安装 nbextensions 时遇到了一些麻烦。我尝试使用 conda,但当我按照此处的说明进行操作时,它终于起作用了。

4

3 回答 3

2

在这里找到了解决方案。基本上,您需要删除或重命名您的 jupyter_nbconvert_config 文件。

于 2016-10-21T22:15:35.427 回答
2

我今天遇到了同样的问题。似乎这是 nbconvert 中的一个错误,如此所述。解决方案是编辑您的“jupyter_nbconvert_config.json”文件。对我来说,它默认位于我的主目录中:/home/me/.jupyter/jupyter_nbconvert_config.json

在那里,我更改了预处理器字符串,在它们前面添加了一个“r”:

{
  "Exporter": {
    "template_path": [
      ".", 
      "/usr/lib/python2.7/site-    packages/jupyter_contrib_nbextensions/templates"
    ], 
    "preprocessors": [
      r"jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor", 
      r"jupyter_contrib_nbextensions.nbconvert_support.PyMarkdownPreprocessor"
    ]
  }, 
  "NbConvertApp": {
    "postprocessor_class":     "jupyter_contrib_nbextensions.nbconvert_support.EmbedPostProcessor"
  }, 
  "version": 1
}
于 2016-08-24T16:31:49.517 回答
1

此错误最近已修复,请参阅此处的详细信息。运行 ipython 的完整更新,或者手动修复:

将 ipython_genutils/importstring.py 中的第 31 行从

module = __import__(package, fromlist=[obj])     

module = __import__(package, fromlist=[str(obj)])
于 2016-12-21T16:19:46.740 回答