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

9

12

I keep on getting error message:

Available subcommands: 1.0.0
Jupyter command `jupyter-nbconvert` not found.

I've tried to reinstall nbconvert using pip to no use. I've also tried the tip from this thread with installing pip install jupyter in vscode terminal but it shows that "Requirement already satisfied" VSCode fails to export jupyter notebook to html

I've also tried to manually edit jupyter settings.json file to the following:

"python.pythonPath": "C:\\Users\\XYZ\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\Scripts"

I've python 3.9 installed via windows store. Any tip on what might be the issue for vscode doesn't want to export the notebook?

Own answered 1/1, 2022 at 23:29 Comment(0)
O
3

Unsure exactly what fixed the issue but heres a summary.

  1. Updated to python 3.10
  2. Installed pandoc and miktex
  3. Powershell reinstall nbconvert
  • Received warning that nbconvert script file is installed in a location not in Path.
  • Copied said location to System Properties - Envionment Variables - Path
  1. Restart and install all miktex package on the go

PDF export and HTML export seems to work as intended now.

Own answered 24/5, 2022 at 20:51 Comment(1)
How do you install nbconvert in powershell?Boarer
B
14
  1. pip uninstall nbconvert

  2. run CMD as admin

  3. pip install nbconvert

Following above steps resolved my issue. Got this solution from this thread

Brittaniebrittany answered 3/2, 2022 at 12:11 Comment(5)
changed the directory path to the python.exe to the crrect version, but still the same error...Takao
error message: 'pip' is not recognized as an internal or external command, operable program or batch file. Also, what I actually need to run is pip3. How do I make these commands work?Boarer
@Boarer have you added python Scripts folder to the path environment variable ? btw if pip3 is already working just run above commands using pip3 instead of pipBrittaniebrittany
This should not be needed, but it does the trick. 👍Junitajunius
Thanks for sharing the GitHub link. This one did the trick for me as I use Ubuntu as OS - github.com/microsoft/vscode-jupyter/issues/… So, I ended up using sudo python3 -m pip uninstall nbconvert followed by sudo python3 -m pip install nbconvert -UDominions
O
3

Unsure exactly what fixed the issue but heres a summary.

  1. Updated to python 3.10
  2. Installed pandoc and miktex
  3. Powershell reinstall nbconvert
  • Received warning that nbconvert script file is installed in a location not in Path.
  • Copied said location to System Properties - Envionment Variables - Path
  1. Restart and install all miktex package on the go

PDF export and HTML export seems to work as intended now.

Own answered 24/5, 2022 at 20:51 Comment(1)
How do you install nbconvert in powershell?Boarer
L
2

Here's my step to convert .ipynb to html:

  1. Install required module: pip install nbconvert
  2. Turn to the folder that contains .ipynb then run jupyter nbconvert --to html Text.ipynb

You may create a new virtual environment to avoid messing up global one then try again.

For your reference: nbconvert-PyPI and create virtual environment.

enter image description here

Lyricism answered 5/1, 2022 at 3:43 Comment(6)
Didn't work. Got message "jupyter: The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program."Own
@CWS. Run pip install jupyter in integrated Terminal.Lyricism
I've done that to no use cause it says requirement already satisfied on all items...Own
@CWS. Okay, first you should check if the jupyter is installed in your current used environment: run pip show jupyter, is it located it current environment\lib\site-packages. Second, once you're sure that the juypter is installed correctly but the command still not work, see if reinstalling the module helps. Besides, post the screenshot in your vscode is sometimes helpful.Lyricism
Running pip show jupyter returns that it is located in c:\users\My_username\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages Does this seem ok? I've tried to reinstall the module using PowerShell as administrator and it doesn't seem to help.Own
mine points to the wrong python version also. in my case 3.8 when i am running 3.9 after a standard pip install...Takao
S
1

I use Pyhton3 and have very limited packages in python, this caused a problem for me.

pip install nbconvert

also try using

pip3 install nbconvert

Stoppage answered 25/1, 2023 at 23:52 Comment(0)
S
0

Quick answer:

import pip
package= ['nbconvert'] # install any package you need without any error forever

for i in package:
    pip.main(['install', i])
Silverts answered 28/2, 2022 at 22:55 Comment(1)
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.Takao
C
0

After facing a similar problem, I tried to resolve it. None of these solutions didn't resolve my problem.

But found an alternative approach, tried opening the notebook by the following command and succeeded.

python -m notebook

If a notebook was not installed in your system, then install it with pip

pip install notebook

After opening your notebook into Jupiter, export it into your desired file.

Cichlid answered 2/11, 2022 at 19:15 Comment(0)
F
0

After spending several hours with this same problem, I finally found a very simple solution. The above solutions did not work for me.

However, in VSCode's settings.json file, there is a line that can be set to extra directories needed by Python. In my case that looks like this:

 "python.analysis.extraPaths": ["/Users/lilly/micromamba/lib/python3.11"],

This important thing seems to be that that directory contains the directory site-packages.

It's relevant to mention that I am getting VSCode to find the Python distribution I want it to use with

"python.defaultInterpreterPath": "/Users/lilly/micromamba/bin/python",

I hope this helps anyone else struggling with the same problem.

Now, I am able to explore to html from within VSCode by choosing ...>Export>HTML from the toolbar

Forbearance answered 25/4, 2023 at 20:20 Comment(0)
B
0

I also had this problem, and reinstalling nbconvert didn't fix it. Following the instructions from here and here, I was ultimately able to make it work by changing the Python kernel to the default kernel instead of my virtual environment.

In the screenshot, I clicked the "Select Kernel" button at the top right, and chose the Python 3.10.11 kernel in ~\AppData\Local\ instead of the one in my virtual environment (labeled .venv in the screenshot). Once I did that, export to HTML worked.

VSCode screenshot showing select kernel dialogue

Belcher answered 22/6, 2023 at 18:19 Comment(0)
T
0

If you're using anaconda distribution, type the following in your terminal to install the jupyter_contrib_nbextensions

conda install -c conda-forge jupyter_contrib_nbextensions

You must also have TeX installed to use the export function on Jupyter Notebook. The TeX distribution can be installed via TeX Live for Windows or MacTeX for MacOS. Just google the respective name to install them, and you shall be fine!

Tiossem answered 19/7 at 5:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.