VS Code Debug Cell button disappears arbitrarily in Jupyter Notebook view
Asked Answered
T

3

20

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?

Tad answered 18/6, 2022 at 18:27 Comment(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?Equerry
I'm experiencing this too. Sometimes closing and reopening the workbook clears the problem; other times I need to close and reopen VS Code.Depalma
E
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.

Enoch answered 10/8, 2023 at 20:51 Comment(0)
R
3

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.

Rothrock answered 24/8, 2023 at 10:32 Comment(1)
August 2024 and the problem still existsIndivertible
B
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).

Broddie answered 15/7 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.