如何帮助 Python 找到 Jupyter 命令 'jupyter-nbconvert',将 Jupyter Notebook 导出到 HTML?
How do I help Python find Jupyter command 'jupyter-nbconvert', to export Jupyter Notebook to HTML?
更新 - 已找到解决方案,请参阅评论,并在本 post 结尾获取更多详细信息
我在 VS Code 中使用 Jupyter Notebook,并尝试通过以下方式将我的笔记本导出到 HTML
Notebook menu tab
换句话说,我正在按照 this page
的说明进行操作
我在尝试将 Jupyter Notebook 导出为 HTML 或 PDF 时遇到此错误(在“输出”的末尾):
Jupyter command `jupyter-nbconvert` not found.
at a.executeCommand (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1000940)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async a.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1007072)
at async _.exportToFormat (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1015303)
at async _.performNbConvertExport (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1014517)
at async _.performExport (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1014153)
at async _.exportImpl (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1013602)
at async _.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1013335)
at async b.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:62972)
at async o._executeContributedCommand (c:\Users\EJJ\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:83:31325)]
我的sys.path是:
['c:\Users\EJJ\Documents\Python',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\python310.zip',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\DLLs',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib',
'C:\Users\EJJ\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0',
'',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win32',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win32\lib',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\Pythonwin',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\site-packages',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert\exporters']
我认为 nbconvert 包安装在:
C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert
,我发现在我的 sys.path 中倒数第三。
我的问题和这个问题有点相似:
由于与该问题的相似性,我尝试按照该线程中给出的建议进行操作。我发现通过 运行 以下命令导出:
python -m jupyter nbconvert --to HTML Unitled-1.ipynb
也不适用于我的安装。我没有得到 HTML 文件,而是列出了一些选项,错误消息
Jupyter command 'jupyter-nbconvert' not found
我也尝试了以下步骤:
- 正在卸载 nbconvert,然后以管理员身份使用 PowerShell 重新安装
- 正在卸载 Jupyter,然后以管理员身份使用 PowerShell 重新安装
- 运行 以下命令:
setx PATH "%PATH%;C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts"
为了尝试提供更多关于我的安装的信息,我 运行 命令 python -m jupyter --version
。这产生了:
Selected Jupyter core packages...
IPython : 8.3.0
ipykernel : 6.13.0
ipywidgets : 7.7.0
jupyter_client : 7.3.1
jupyter_core : 4.10.0
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.3
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.11
qtconsole : 5.3.0
traitlets : 5.2.1.post0
最后,我只是想收集一些描述相同问题的post,因为我怀疑它们没有得到解决。希望从这个问题中学到的任何知识可能有助于解决这些问题:
https://github.com/microsoft/vscode-jupyter/issues/4347
VSCode fails to export jupyter notebook to html
Unable to convert Jupyter Notebooks into python scripts Jupyter command `jupyter-nbconvert` not found
https://github.com/microsoft/vscode-jupyter/issues/10096(解决方法在这里,看评论)
解决方案
在 VScode 中,按 CTRL+Shift+P(默认设置)打开“命令面板”(也可在“查看”选项卡下找到)
在字段中写入Jupyter : Select interpreter to start Jupyter server
选择其他版本的python(Windows存储在我的案例中-参见)
尝试再次导出,如果 VSCode 要求,请再次同意安装 Jupyter。
您可以使用vscode中的导出工具将其转换为pdf。
有关详细信息,请转到此 link
您可以尝试使用此命令:
Jupyter : Select interpreter to start Jupyter server
并选择安装了 nbconvert 的 python 环境。
或者,您可以将 nbconvert 安装到我们 运行 您的笔记本所使用的环境中。应该是这个:
~\AppData\Local\Programs\Python\Python310\python.exe
更新 - 已找到解决方案,请参阅评论,并在本 post 结尾获取更多详细信息
我在 VS Code 中使用 Jupyter Notebook,并尝试通过以下方式将我的笔记本导出到 HTML Notebook menu tab
换句话说,我正在按照 this page
的说明进行操作我在尝试将 Jupyter Notebook 导出为 HTML 或 PDF 时遇到此错误(在“输出”的末尾):
Jupyter command `jupyter-nbconvert` not found.
at a.executeCommand (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1000940)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async a.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1007072)
at async _.exportToFormat (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1015303)
at async _.performNbConvertExport (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1014517)
at async _.performExport (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1014153)
at async _.exportImpl (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1013602)
at async _.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:1013335)
at async b.export (c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\out\extension.node.js:2:62972)
at async o._executeContributedCommand (c:\Users\EJJ\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:83:31325)]
我的sys.path是:
['c:\Users\EJJ\Documents\Python',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\python310.zip',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\DLLs',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib',
'C:\Users\EJJ\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0',
'',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win32',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win32\lib',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\Pythonwin',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0',
'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\site-packages',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert',
'c:\Users\EJJ\.vscode\extensions\ms-toolsai.jupyter-2022.4.1021342353\pythonFiles\vscode_datascience_helpers\getVariableInfo',
'C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert\exporters']
我认为 nbconvert 包安装在:
C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert
,我发现在我的 sys.path 中倒数第三。
我的问题和这个问题有点相似:
由于与该问题的相似性,我尝试按照该线程中给出的建议进行操作。我发现通过 运行 以下命令导出:
python -m jupyter nbconvert --to HTML Unitled-1.ipynb
也不适用于我的安装。我没有得到 HTML 文件,而是列出了一些选项,错误消息
Jupyter command 'jupyter-nbconvert' not found
我也尝试了以下步骤:
- 正在卸载 nbconvert,然后以管理员身份使用 PowerShell 重新安装
- 正在卸载 Jupyter,然后以管理员身份使用 PowerShell 重新安装
- 运行 以下命令:
setx PATH "%PATH%;C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts"
为了尝试提供更多关于我的安装的信息,我 运行 命令 python -m jupyter --version
。这产生了:
Selected Jupyter core packages...
IPython : 8.3.0
ipykernel : 6.13.0
ipywidgets : 7.7.0
jupyter_client : 7.3.1
jupyter_core : 4.10.0
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.3
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.11
qtconsole : 5.3.0
traitlets : 5.2.1.post0
最后,我只是想收集一些描述相同问题的post,因为我怀疑它们没有得到解决。希望从这个问题中学到的任何知识可能有助于解决这些问题:
https://github.com/microsoft/vscode-jupyter/issues/4347
VSCode fails to export jupyter notebook to html
Unable to convert Jupyter Notebooks into python scripts Jupyter command `jupyter-nbconvert` not found
https://github.com/microsoft/vscode-jupyter/issues/10096(解决方法在这里,看评论)
解决方案
在 VScode 中,按 CTRL+Shift+P(默认设置)打开“命令面板”(也可在“查看”选项卡下找到)
在字段中写入Jupyter : Select interpreter to start Jupyter server
选择其他版本的python(Windows存储在我的案例中-参见
尝试再次导出,如果 VSCode 要求,请再次同意安装 Jupyter。
您可以使用vscode中的导出工具将其转换为pdf。
有关详细信息,请转到此 link
您可以尝试使用此命令:
Jupyter : Select interpreter to start Jupyter server
并选择安装了 nbconvert 的 python 环境。
或者,您可以将 nbconvert 安装到我们 运行 您的笔记本所使用的环境中。应该是这个:
~\AppData\Local\Programs\Python\Python310\python.exe