在以下路径中找不到名为“lab”的模板子目录

我正在运行一个 python azure 函数,它通过nbconvertAPI 运行一个 jupyter 笔记本。这已经工作了一段时间,尽管没有部署新代码,我开始收到以下错误:


No template sub-directory with name 'lab' found in the following paths:

    /home/.local/share/jupyter

    /usr/local/share/jupyter

    /usr/share/jupyter

我用来实现此目的的代码是:


from nbconvert.preprocessors import ExecutePreprocessor

from nbconvert import HTMLExporter


...


dl = DictLoader({'footer':

"""

{%- extends 'full.tpl' -%}


{% block input_group %}

    {%- if cell.metadata.get('nbconvert', {}).get('show_code', False) -%}

        ((( super() )))

    {%- endif -%}

{% endblock input_group %}

{% block output_group %}

    <style> .output_prompt{visibility:hidden;}</style>

    {{ super() }}

{% endblock output_group %}

"""})


...


html_exporter = HTMLExporter(extra_loaders=[dl], template_file='footer')

html_exporter.template_name = 'classic'

with open(JUPYTER_DIR + NOTEBOOK_NAME) as f:

    nb = nbformat.read(f, as_version=4)


ep = ExecutePreprocessor(timeout=600, kernel_name='python')

ep.preprocess(nb, {'metadata': {'path': JUPYTER_DIR}})

(body, resources) = html_exporter.from_notebook_node(nb)

functionapp 正在运行以下内容:


python3.6

nbconvert6.0.3

jupyter-lab0.1.1

我尝试用谷歌搜索错误,到目前为止我发现的最接近的东西是这个,它相似但未得到答复且不完全相同。我想我会在这里发帖看看是否有人知道如何解决或让我更新如果我设法解决问题。


我很困惑,因为lab这不是我熟悉的关键字(在 Maybe 之外jupyterlab)并且没有在代码中使用。


至于提到的路径:


home/.local/share/jupyter/存在并包含nbconvert/templates/html

usr/local/share/jupyter&usr/share/jupyter不存在

预先感谢您的任何帮助!


宝慕林4294392
浏览 150回答 6
6回答

catspeake

将 nbconvert 升级到 6.0.8 后,我遇到了同样的问题。回滚到 nbconvert 5.6.1 解决了我的问题。pip uninstall nbconvertpip install nbconvert==5.6.1

FFIVE

对我来说,卸载和安装 nbconvert 使用:pip&nbsp;uninstall&nbsp;nbconvert pip&nbsp;install&nbsp;nbconvert修正了这个错误。

SMILET

在 Mac 上,如果您在用户模式下使用 pip3 安装了 jupyterln&nbsp;-s&nbsp;~/Library/Python/3.8/share/jupyter/nbconvert&nbsp;~/Library/Jupyter/nbconvert只需将 3.8 替换为合适的版本即可

慕侠2389804

pip install -U nbconvert安装了 .../site-packages/share/jupyter/nbconvert/templates/但jupyter nbconvert my.ipynb --to python看不到那里--# ValueError: No template sub-directory with name 'base' found in the following paths:/Users/myuserid/Library/Jupyter&nbsp; # mac/Library/Frameworks/Python.framework/Versions/3.7/share/jupyter/usr/local/share/jupyter/usr/share/jupyter在其中之一中创建一个符号链接.../site-packages/.../templates,例如cd $HOME/Library/Jupyter/nbconvert&nbsp; # mac, other platforms dunnomv templates templates-tmp&nbsp; # emptyln -s .../site-packages/share/jupyter/nbconvert/templates .ls templates/# asciidoc/&nbsp; classic/&nbsp; &nbsp; &nbsp; html/&nbsp; latex/&nbsp; &nbsp; &nbsp;python/&nbsp; rst/# base/&nbsp; &nbsp; compatibility/&nbsp; lab/&nbsp; &nbsp;markdown/&nbsp; reveal/&nbsp; script/

慕尼黑5688855

在 Mac 上,与 @denis 解决方案非常相似,只是位置不同:cd /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/share/jupyter/nbconvert/mv templates templates-tmpln -s /opt/homebrew/share/jupyter/nbconvert/templates

红糖糍粑

我遇到了同样的错误。我假设默认/内置模板刚刚在 anaconda 安装期间安装。我认为我们必须查看旧版本的 jupyter notebook / nbconvert / anaconda 并复制并粘贴模板文件。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python