Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug fails in python jupyter notebook where cells have execution_count: null #1669

Open
jtbr opened this issue Sep 11, 2024 · 1 comment
Open
Labels
needs repro Issue has not been reproduced yet

Comments

@jtbr
Copy link

jtbr commented Sep 11, 2024

I have notebooks which have cells having the json attribute "execution_count" set to null.
This is common with tools, such as nbdev-clean which attempt to reduce diff-noise when saving notebooks in source control.

Unfortunately, it seems to make it impossible to debug in such notebooks from within VS Code's Python extension.

Here is a trace:

cd /home/user/project ; /usr/bin/env /opt/mambaforge/envs/orion/bin/python /home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47789 -- /home/user/project/ml_ann_experiments.ipynb 
Traceback (most recent call last):
  File "/opt/mambaforge/envs/orion/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/mambaforge/envs/orion/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/user/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/home/user/project/a_notebook.ipynb", line 427, in <module>
    "execution_count": null,
NameError: name 'null' is not defined

Here are software info:

VS Code
Version: 1.92.2
Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
Date: 2024-08-14T17:29:30.058Z (4 wks ago)
Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.92.2 Chrome/124.0.6367.243 Electron/30.1.2 Safari/537.36

Python Extension
Published 2016-01-19, 16:03:11
Last released 2024-09-05, 23:24:18
Last updated 2024-09-06, 07:23:15
Identifier ms-python.python

Python Debugger
Published 2023-06-14, 20:20:56
Last released 2024-08-29, 12:33:08
Last updated 2024-08-14, 22:13:57
Identifier ms-python.debugpy

python 3.10.13
ipython 8.15.0
debugpy 1.6.7

I'm running on linux mint 21.2

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python-debugger Sep 12, 2024
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Sep 12, 2024
@judej judej assigned debonte and unassigned AdamYoblick and debonte Oct 14, 2024
@judej
Copy link

judej commented Oct 22, 2024

@jtbr, it appears that the "execution_count": null in your a_notebook.ipynb file is being treated as a line of Python instead of json. One way to check if that is true would be to edit the notebook file and change that null to 0. Hopefully, that will let you go forward.

That being said, this is a bug in the way the debugpy launcher is setting up the debugging environment. It seems the launcher is not correctly handling the JSON structure of the notebook. Please lmk if this work around works for now.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants