VSCode无法将Jupyter笔记本导出为html。

8

我在VSCode中有一个jupyter笔记本,尝试使用VSCode内置的按钮将其导出为html,但是我一直收到此错误:“Jupyter命令jupyter-nbconvert未找到”。

我正在使用pip,并且已经安装了所有我能想到的与jupyter相关的软件包:jupyter,jupyterlab,nbconvert,notebook。

有什么想法可能导致这个问题? 我正在使用Windows 10。

> C:\Python38\python.exe c:\Users\Toshiba\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\pyvsc-run-isolated.py jupyter nbconvert --version
> C:\Python38\python.exe c:\Users\Toshiba\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\pyvsc-run-isolated.py jupyter nbconvert --version
Error 2020-10-26 10:40:19: Export failed [r [Error]: Traceback (most recent call last):
  File "c:\Users\Toshiba\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\pyvsc-run-isolated.py", line 26, in <module>
    runpy.run_module(module, run_name="__main__", alter_sys=True)
  File "C:\Python38\lib\runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "C:\Python38\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Toshiba\AppData\Roaming\Python\Python38\site-packages\jupyter.py", line 4, in <module>
    main()
  File "C:\Users\Toshiba\AppData\Roaming\Python\Python38\site-packages\jupyter_core\command.py", line 247, in main
    command = _jupyter_abspath(subcommand)
  File "C:\Users\Toshiba\AppData\Roaming\Python\Python38\site-packages\jupyter_core\command.py", line 133, in _jupyter_abspath
    raise Exception(
Exception: Jupyter command `jupyter-nbconvert` not found.


在 VSCode 终端中输入 "jupyter nbconvert --version",它会输出其版本号吗?由于 VSCode 中的 Jupyter 笔记本功能是由 Python 扩展提供的,建议您使用最新版本的 Python 扩展或尝试其他版本的 Python 扩展。 - Jill Cheng
当我在VSCode终端中输入这个命令时,我会得到以下错误信息:jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.我已经安装了最新版本的VSCode Python扩展程序,即2020.9.114305。是否更好地在他们的Github上提出问题? - Miguel
你可以尝试使用"python -m notebook"命令,并尝试使用不同的VSCode环境。 - Jill Cheng
2个回答

2
  1. pip uninstall nbconvert

  2. 以管理员身份运行CMD

  3. pip install nbconvert

我也遇到了同样的问题,按照上述步骤解决了。这个解决方案来自于此帖子


-2

你正在使用jupyter扩展,但是你没有在你的Python解释器中安装jupyter。只需执行'pip install jupyter',导出就可以工作了。 如果你正在使用venv或其他虚拟环境,你应该在那里安装jupyter。


嗨,Elliot!请在发布答案时正确格式化您的代码。您可以在这里了解更多信息。 - BiOS
谢谢!Elliot编写的解决方案完美无缺。 - Akhan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接