Answer a question

UPDATE - A solution was found, see comments, and the end of this post for further details

I am using Jupyter Notebook in VS Code, and trying to export my notebook to HTML through the Notebook menu tab

In other words, I am following the instructions from this page

I am getting this error (in the end of "Output"), when trying to export a Jupyter Notebook to HTML or 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)]

My sys.path is:

['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']

and the nbconvert package I think is installed at:

C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nbconvert

, which I find to be third from the bottom in my sys.path.

My issue seems somewhat similar to this issue: VScode fails to export Jupyter notebook to HTML - 'jupyter-nbconvert` not found

Because of the similarity to the issue, I have tried to follow the suggestions given in that thread. I found that exporting by running the following command:

python -m jupyter nbconvert --to HTML Unitled-1.ipynb

did also not work for my installation. Instead of getting an HTML file, I got some options listed, and the error message

Jupyter command 'jupyter-nbconvert' not found

I also tried the following steps:

  • Uninstalling nbconvert, and reinstalling using PowerShell as administrator
  • Uninstalling Jupyter, and reinstalling using PowerShell as administrator
  • Running the following command:
setx PATH "%PATH%;C:\Users\EJJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts"

To try and give some more information about my installation, I ran the command python -m jupyter --version. This produced:

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

In the end, I just wanted to gather some posts which describes the same issue, since I suspect them to not be resolved. Hopefully, any learnings from this issue might help resolve those:

https://github.com/microsoft/vscode-jupyter/issues/4347

VScode fails to export Jupyter notebook to HTML - 'jupyter-nbconvert` not found

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 (The solution is here, see comments)

Solution

In VScode, press CTRL+Shift+P (default setting) to open "Command Palette" (also found under "View"-tab)

Write Jupyter : Select interpreter to start Jupyter server in the field

Choose the other version of python (Windows Store in my case - see this picture)

Try to export again, and say yes to installing Jupyter again if VSCode asks to.

Answers

You might try using this command:

Jupyter : Select interpreter to start Jupyter server and pick the python environment where you have nbconvert installed.

Alternatively you could install nbconvert into the environment we're using to run your notebook. It should be this one:

~\AppData\Local\Programs\Python\Python310\python.exe
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐