CWS
CWS

Reputation: 161

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

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?

Upvotes: 13

Views: 42036

Answers (9)

Future Liang
Future Liang

Reputation: 36

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!

Upvotes: 0

Jake Fisher
Jake Fisher

Reputation: 3310

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

Upvotes: 0

Jonathan Lilly
Jonathan Lilly

Reputation: 1

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

Upvotes: 0

vijay kumar
vijay kumar

Reputation: 431

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

Upvotes: 1

Nayeem Bin Ahsan
Nayeem Bin Ahsan

Reputation: 471

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.

Upvotes: 0

CWS
CWS

Reputation: 161

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.

Upvotes: 3

myworldbox
myworldbox

Reputation: 413

Quick answer:

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

for i in package:
    pip.main(['install', i])

Upvotes: 0

Chamod
Chamod

Reputation: 767

  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

Upvotes: 15

Molly Wang-MSFT
Molly Wang-MSFT

Reputation: 9451

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

Upvotes: 2

Related Questions