vscode-jupyter: Exporting notebooks to script requires Jupyter nbconvert but users is not prompted to do so.

Environment data

  • VS Code version: 1.53.3
  • Jupyter Extension version (available under the Extensions sidebar): v2021.3.619093157
  • Python Extension version (available under the Extensions sidebar): v2021.3.658691958
  • OS (Windows | Mac | Linux distro) and version: Win20H2
  • Python and/or Anaconda version: 3.8.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Jupyter server running: Local

Repro steps:

  1. Have venv with jupyter and tensorflow
  2. Navigate to the folder with venv in terminal, launch code .
  3. Open saved .ipynb file (opens with correct venv python
  4. Select “Convert a Notebook to Python Script”

Expected behaviour

Works

Actual behaviour

Fails with:

User belongs to experiment group 'jupyterTestcf'
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import notebook"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import jupyter"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py pip list
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py jupyter kernelspec --version
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
Error 2021-03-20 01:26:58: Jupyter Kernel Spec not found for a local connection
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
Started kernel Python 3.8.2 64-bit ('venv')
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c "import nbconvert"
> c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py jupyter nbconvert --version
Error 2021-03-20 01:27:03: Export failed Error: Importing notebooks requires Jupyter nbconvert to be installed.
    at g.importFromFile (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:492139)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at s.export (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:260294)
    at _.exportToFormat (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:257809)
    at _.performExport (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:256994)
    at _.export (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:256508)
    at c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:418329
    at u.waitWithStatus (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:828995)
    at E.importNotebook (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:418249)
    at E.listenForErrors (c:\Users\houskape\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\out\client\extension.js:49:414146)
    at S._executeContributedCommand (c:\Users\houskape\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:87:103766)

while nbconvert is installed in active venv:

PS C:\Users\houskape\source\repos\NDN4-playground> & c:/Users/houskape/source/repos/NDN4-playground/venv/Scripts/Activate.ps1
(venv) PS C:\Users\houskape\source\repos\NDN4-playground> python -m pip install "nbconvert"
Requirement already satisfied: nbconvert in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (6.0.7)
Requirement already satisfied: mistune<2,>=0.8.1 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.8.4)
Requirement already satisfied: pygments>=2.4.1 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (2.7.2)    
Requirement already satisfied: jupyterlab-pygments in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.1.2)
Requirement already satisfied: bleach in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (3.2.1)
Requirement already satisfied: jupyter-core in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (4.7.0)
Requirement already satisfied: nbformat>=4.4 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (5.0.8)
Requirement already satisfied: defusedxml in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.6.0)
Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.5.1)
Requirement already satisfied: testpath in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.4.4)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (1.4.3)
Requirement already satisfied: jinja2>=2.4 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (2.11.2)
Requirement already satisfied: traitlets>=4.2 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (5.0.5)
Requirement already satisfied: entrypoints>=0.2.2 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbconvert) (0.3)
Requirement already satisfied: webencodings in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from bleach->nbconvert) (0.5.1)
Requirement already satisfied: six>=1.9.0 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from bleach->nbconvert) (1.15.0)
Requirement already satisfied: packaging in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from bleach->nbconvert) (20.5)
Requirement already satisfied: pywin32>=1.0; sys_platform == "win32" in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jupyter-core->nbconvert) (300)
Requirement already satisfied: ipython-genutils in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbformat>=4.4->nbconvert) (0.2.0)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbformat>=4.4->nbconvert) (3.2.0)
Requirement already satisfied: async-generator in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert) (1.10)
Requirement already satisfied: jupyter-client>=6.1.5 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert) (6.1.7)
Requirement already satisfied: nest-asyncio in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert) (1.4.3)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jinja2>=2.4->nbconvert) (1.1.1)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from packaging->bleach->nbconvert) (2.4.7)
Requirement already satisfied: setuptools in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert) (41.2.0)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert) (0.17.3)
Requirement already satisfied: attrs>=17.4.0 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert) (20.3.0)
Requirement already satisfied: pyzmq>=13 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert) (20.0.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert) (2.8.1)
Requirement already satisfied: tornado>=4.1 in c:\users\houskape\source\repos\ndn4-playground\venv\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert) (6.1)
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
(venv) PS C:\Users\houskape\source\repos\NDN4-playground> 

Correct interpreter is selected: image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 32 (16 by maintainers)

Most upvoted comments

Sorry for the late response and thanks everyone for commenting your solutions. From what I’m reading, we should prompt users to install missing dependencies (nbconvert, notebook, jupyter).

@rikkigouda, @juanbomfim22, @autoscraper and @petrroll, does this solve your issue?

We need to understand why this is failing for some people. We need at minimum to add some logging.

@goudarzi Ahh, that log is not super helpful unfortunately, and it seems you’re hitting a separate issue: https://github.com/microsoft/vscode-jupyter/issues/6879 Really sorry about that. What is your active interpreter (bottom left status bar)? Does it match the interpreter for your kernel?

@goudarzi There should be more info in the output panel providing info on which python.exe we’re trying to use. Would you mind sending all of it? You may need to configure “jupyter.logging.level”: “debug” in your user settings.json if there isn’t more output. The beginning of the log should look something like this:

image

@goudarzi Would you mind providing the full logs from the Jupyter output panel after exporting fails? That should have more info re: why this is happening.

I opened settings.json and added "python.pythonPath" with the path of the interpreter. That fixed it but I’m not sure why since I can’t reproduce it anymore.

@goudarzi

  1. What is the path to your Python interpreter? If you don’t know what this is, you can run the following code in a cell:
import sys
print(sys.executable)
  1. Can you try running <path to your interpreter> -m pip install nbconvert from the command line, then try exporting again?

Can folks in this thread confirm that the problem persists with the latest version of the Jupyter extension, v2021.5.745244803?

If the problem does persist, can I ask your help with trying something? In the Jupyter output log you should see a command like the following (with usernames and paths varying):

c:\Users\houskape\source\repos\NDN4-playground\venv\Scripts\python.exe c:\Users\houskape.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157\pythonFiles\pyvsc-run-isolated.py -c “import nbconvert”

This is the command we use to check if nbconvert is installed into the current interpreter. Would y’all be able to run the above command (swapping out the paths as appropriate) in your terminal and paste the output in a new comment? That will help us understand why we are failing to detect nbconvert being installed. Thanks!