question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debug Cells / Run Cells are selecting wrong cell / wrong lines after 2nd Debug Cell. Freezes after 3rd Debug Cell.

See original GitHub issue

Environment data

  • VS Code version: 1.60.0
  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.2041215044
  • Python Extension version (available under the Extensions sidebar): 3.7/2.7/3.9 (all)
  • OS (Windows | Mac | Linux distro) and version: Mac 11 & Ubuntu 20
  • Python and/or Anaconda version: 3.7/2.7/3.9 (all)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv & no environment affected
  • Jupyter server running: Issue on Local & Remote

Expected behaviour

This is a 100% clean install. Problem is on Mac OS and Ubuntu.

I have a plain .py file and use “# %%” Cell Marker (jupyter.defaultCellMarker). When I click “Debug Cell”, it debugs the cell properly. When I click on any random cell, it debugs that cell properly line-by-line. When I interrupt the kernel, it stops, but allows me to debug cells.

Actual behaviour

When I click “Debug Cell”, it will only allow me to debug that cell and ONLY that cell. This prevents me from debugging any other cell. If I try to debug another cell, it will still highlight the first cell that was debugged. However, the output will be from the selected cell.

Issue exists on mac and ubuntu with clean installs of VSCode + Extensions.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Create a .py file
  2. Add the following code to the file:
# %%
print(1)
print(2)
print(3)
# %%
print(4)
print(5)
print(6)
# %%
print(7)
print(8)
print(9)
  1. In VS Code, select the second cell’s “Debug Cell” command.
  2. Iterate through print lines 4, 5, 6.
  3. In VS Code, select the third cell’s “Debug Cell” command.
  4. It will select cell with print statements for 4, 5, 6, instead of 7, 8, 9. When iterating, the output will be 7, 8, 9. Which doesn’t match the selected cell.
  5. Select the first cell.
  6. Extension will freeze. There will be no ability to iterate / debug the cell. Interrupting the kernel does not work. Only kernel restart works.

vscode_problem

Any ideas about a workaround or a fix for this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidKutucommented, Sep 13, 2021

Thanks for getting back to us @ThisntWorking.

We meant the ipykernel version. For instance, if you’re using pip run pip show ipykernel and that should show the version.

1reaction
greazercommented, Sep 13, 2021

This may be related to the version of ipykernel you have installed in your environment. What is it? If it’s version 6, it’s a known issue #7141

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect line number in debugging cells · Issue #8263 - GitHub
Debug at the incorrect line. Steps to reproduce: Create and run a cell (cell A) containing a function definition with 'def' at the...
Read more >
Excel Macro Troubleshooting Tips Debug and F8 Key Problems
Troubleshoot Excel macro if error message appears. Use Debug button to find and fix simple problem. Fix F8 key stops working.
Read more >
Excel 2010 crashes after selecting debug macro
I am trying to debug this code, but upon running it, the macro stops giving me a Microsoft Visual Basic Run-time error '-2147417848...
Read more >
Error when debugging a jupyter notebook in VSCode when a ...
Run by Line Run by Line lets you execute a cell one line at a time, without being distracted by other VS Code...
Read more >
PyCharm - Run and debug Jupyter notebook code cells
The debugger may skip a cell if you change its source code or execute it not under the debugger. Also, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found