19

I am developing a Python script in a Jupyter Notebook (ipynb file) in Visual Studio Code.

Arbitrarily, the "Debug Cell" run option disappears and I have not found a way yet to debug a specific notebook cell in a different way. I am just able to run the cell, but there is no way to debug the cell.

No "Debug Cell" option clickable in VS Code

According to the VS Code documentation on "Jupyter Notebooks in VS Code - Debug a Jupyter Notebook" there should be this arrow visible, which allows to click on "Debug Cell".

Debug Cell image from VS Code Documentation

After restarting VS Code the Debug option is usually again visible.

What am I doing wrong that this "Debug Cell" option becomes invisible for me or is this probably a bug? Has anyone else noticed this issue yet?

2
  • Did you try uninstalling jupyter and then reinstalling? Or create a new virtual environment to start using jupyter again. Also, is it possible to debug directly using the shortcut keys in the screenshot?
    – JialeDu
    Commented Jun 20, 2022 at 6:11
  • 3
    I'm experiencing this too. Sometimes closing and reopening the workbook clears the problem; other times I need to close and reopen VS Code. Commented Jan 26, 2023 at 16:33

3 Answers 3

7

It is a known bug in VS Code and is still an open issue on their GitHub as of writing this answer. (1+ years..)

The suggested workaround is to use 'Developer: Reload Window' from the command palette. It is only marginally faster than restarting VS Code altogether and you will lose workspace variables, remote connections, etc.

0
2

This is the subject of a bug ticket: Debug Cell option disappears #150219.

People have found various workarounds:

  • One workaround people have found is to reload the window, which you can do by using the Developer: Reload Window command in the command palette. Note that this may cause some state of the Jupyter Notebook to be lost, which makes it a bit non-ideal as a workaround.

  • Another user has found that the issue doesn't happen if they open the Notebook file directory instead of opening a folder containing it as a workspace folder, and that deleting the project's venv and recreating it caused the issue to no longer happen.

  • Another user found that switching to another venv, the problem didn't happen there, though it still happened in the previous venv.

  • Another user found that removing the "Typing" module from the env helped. Ex. %pip uninstall typing -y.

  • Another user found that the keyboard shortcut to debug the cell still worked for them: ctrl+shift+alt+enter.

  • Another user found that they had the message "[IPKernelApp] WARNING | debugpy_stream undefined, debugging will not be enabled" in their jupyter-notebook logs, and that installing the python-debugpy package fixed the issue.

0

I had the same problem with our Linux server and tried the solutions mentioned here or elsewhere, but they haven't worked yet. As Divyansh mentioned, it's still an open issue.

To solve this issue, I created a new environment and tried to install a new version of Python as well as Jupyter. It worked for me. I tried this in WSL with conda env as well as the regular Python path without an environment. It worked there without needing to reinstall VS Code or to remove the vscode-server directory. It seems that this issue stems from some conflict between packages (just my guess).

Not the answer you're looking for? Browse other questions tagged or ask your own question.