![](/img/trans.png)
[英]VScode fails to export Jupyter notebook to HTML - 'jupyter-nbconvert` not found
[英]How do I help Python find Jupyter command 'jupyter-nbconvert', to export Jupyter Notebook to HTML?
更新 - 找到了解決方案,請參閱評論,並在本文末尾了解更多詳細信息
我在 VS Code 中使用 Jupyter Notebook,並嘗試通過Notebook 菜單選項卡將我的筆記本導出為 HTML
換句話說,我正在按照此頁面的說明進行操作
嘗試將 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 中排在倒數第三位。
我的問題似乎有點類似於這個問題: VScode failed to export Jupyter notebook to HTML - 'jupyter-nbconvert` not found
由於與問題相似,我試圖遵循該線程中給出的建議。 我發現通過運行以下命令導出:
python -m jupyter nbconvert --to HTML Unitled-1.ipynb
也不適用於我的安裝。 我沒有獲得 HTML 文件,而是列出了一些選項,以及錯誤消息
Jupyter command 'jupyter-nbconvert' not found
我還嘗試了以下步驟:
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
最后,我只是想收集一些描述相同問題的帖子,因為我懷疑它們沒有得到解決。 希望從這個問題中學到的任何東西都可以幫助解決這些問題:
https://github.com/microsoft/vscode-jupyter/issues/4347
VScode 無法將 Jupyter 筆記本導出為 HTML - 找不到“jupyter-nbconvert”
VSCode 無法將 jupyter notebook 導出到 html
無法將 Jupyter Notebooks 轉換為 Python 腳本 Jupyter 命令“jupyter-nbconvert”未找到
https://github.com/microsoft/vscode-jupyter/issues/10096 (解決方案在這里,見評論)
解決方案
在 VScode 中,按 CTRL+Shift+P(默認設置)打開“命令面板”(也可以在“視圖”選項卡下找到)
編寫Jupyter : Select interpreter to start Jupyter server
選擇其他版本的python(在我的情況下是Windows Store - 請參閱 )
嘗試再次導出,並在 VSCode 要求時再次同意安裝 Jupyter。
您可以嘗試使用以下命令:
Jupyter : Select interpreter to start Jupyter server
並選擇安裝了 nbconvert 的 python 環境。
或者,您可以將 nbconvert 安裝到我們用來運行筆記本的環境中。 應該是這個:
~\AppData\Local\Programs\Python\Python310\python.exe
欲了解更多信息,請訪問此鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.