vscode-jupyter
vscode-jupyter copied to clipboard
"Debug cell" not working in Jupyter notebooks when typings module is installed
Environment data
- VS Code version: Visual Studio Code (1.76.0, undefined, desktop)
- Jupyter Extension version (available under the Extensions sidebar): 2023.2.1200692131.
- Python Extension version (available under the Extensions sidebar): 2023.4.1.
- OS (Windows | Mac | Linux distro) and version: MacOS Monterey 12.5.1 (21G83)
- Python and/or Anaconda version: 3.9.10
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
- Jupyter server running: Local
Expected behaviour
Debug cell and the debugger should be working properly on Jupyter notebooks
Actual behaviour
At first, the option is available, but when I click on it, the debugger fires up but does nothing and the debug cell
button disappears.
before:
after clicking on debug cell
:
and I get this error too when relaunching:
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- Just open any local Jupyter notebook and try to debug any cell
Logs
Any updates on the issue? Many thanks!
I don't have exactly this issue. I can't debug as it constantly says "Ipykernel setup required for this feature" even though I'm sure that my ipykernels are installed.
(py39) C:\Users\username>jupyter kernelspec list Available kernels: python3 C:\Users\username.conda\envs\py39\share\jupyter\kernels\python3
as well as for base
(base) C:\Users\username>jupyter kernelspec list Unable to load extension: pydevd_plugins.extensions.types.pydevd_plugin_pandas_types Available kernels: python3 C:\ProgramData\Miniconda3\share\jupyter\kernels\python3
I wonder if this is connected?
@fschiffers please could you file a seprate issue as it looks unrelated, that way we can look at both individually. @garrofederico Sorry for not getting back, please could you try installing VS Code insiders and letting me know if this still exists in the latest pre-releaes version of jupyter extension and pre-release version of the Python extensoin
- Please install latest VS Code Insiders
- Open the extensions page, search for Jupyter and click the button
Switch to Pre-Release Version
- Similarly please install the latest
Pre-Release
version of the Python extension

@DonJayamanne , Thanks for your response.
-
I installed the latest VS Code Insiders
-
I installed the latest
pre-release
of the Python extension -
However, I wasn't able to switch to the
Pre-Release Version
of the Jupyter extension, this option is not available to me inVS Code insiders
norStable
version:
Anyway, I tested debbuging on the Insiders
version and it is still not working.
Hi @garrofederico, maybe it's just that you need to add the breakpoint before starting Debug Cell? I see it in the second screenshot but not the first, so it's not clear if it was there before you started.
If that doesn't help, can you set the setting "jupyter.logging.level": "verbose"
, try again, and grab the log again? Thanks
Hi @roblourens, thanks for helping out.
Here's a screen shot that shows everything at once:
I tested it again (with the breakpoints, of course) and it is not working. Here's the log as you asked: jupyter_console_output_3.log
Yeah, something is going on, it's getting stuck when we start the debugger but I'm not sure why. I can tell you that the restart button will not work currently and will give you that error message though.
Hi, is there any update on this matter? Thanks!
An update: the debugger is working correctly on jupyter notebooks when I'm connected to a remote server.
Is there any update on your side?
I have the same issue. I realized when i import models from super_gradients.training, "Ipykernel setup required for this feature" occurs. otherwise the debug feature works well.
Having the same problem on my Windows Machine:
- VS Code Version: 1.78.2
- OS: Windows 11
- Python Version: 3.10.8
- Jupyter Extension Version: 2023.4.1011241018
- Python Extension Version: 2023.8.0
I get this every time I want to debug some cell
And that's it, breakpoints aren't reached, debugger shows nothing, even the play button stops showing the little arrow at the side
@memeplex I am experiencing the exact same problem.
- VS Code version: Version: 1.79.0 (Universal) Commit: b380da4ef1ee00e224a15c1d4d9793e27c2b6302 Date: 2023-06-07T14:29:00.206Z (1 wk ago) Electron: 22.5.5 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Darwin arm64 22.4.0
- Jupyter Extension version (available under the Extensions sidebar): v2023.5.1001582324
- Python Extension version (available under the Extensions sidebar): v2023.10.1
- OS (Windows | Mac | Linux distro) and version: Local: Ventura Version 13.3.1 (a) (22E772610a)
- Python and/or Anaconda version: 3.10.11 (Python version)
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
- Jupyter server running: Remote (sshing)
I am also having same issue on y system
Version: 1.79.2 (user setup) Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06 Date: 2023-06-14T08:57:04.379Z Electron: 22.5.7 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.22621
Jupyter v2023.5.1101742258
Able to execute cell but I am unable to see Debug cell option in visual studio code
I was able to work around the issue by creating a new virtual environment.
I think I found the root cause for this error, at least for my case:
If you create a virtual environment using virtualenv and you rename or change ANY part of the path where the virtual environment is located, your interpreter will be broken. You won't see any error messages, except in some specific use-cases.
In my case I only found this error while trying to login using huggingface-cli
and the command was not found although the transformers
package was installed correctly and working otherwise. Therefore, I executed the command directly via its installation location .venv/bin/huggingface-cli
and got the following error:
zsh: .venv/bin/huggingface-cli: bad interpreter: /home/some-user/projects/.venv/bin/python: no such file or directory
That's where I saw the missing folder in the path.
As mentioned by @LHLaurini the solution would be to delete the environment and create a new one or change the paths back how they where while installing the environment.
I've been able to reliably reproduce the bug in the following scenario:
setup virtual environment: virtualenv venv
test the debugger -> still works
pip install typing
test the debugger -> still works
restart the kernel
test the debugger -> now I get the error
I still don't understand the issue, but I found that the debugger works if I use conda to make a virtual environment and to install the typing package.
To emphasize, I can pip install any package, or conda install typing. The error only comes up when I "pip install typing" and I restart the kernel.
Met with the same issue.
same issue for me
Suggestion
When debugging, warn users if typings
module is installed
The debug cell in Edge disappeared, but it works normally in Chrome
Successfully fixed debugging in Jupyter notebook in VSCode
Summarizing the findings of all related threads in a single post to help the many others wasting time debugging this.
:x: Before: Error | ✅ After: Working! |
---|---|
Diagnosing the Problem
First, look at the Jupyter
extension logs:
Unfortunately, you may only receive this as the last log message:
16:56:43.944 [info] Starting debugging with mode 1
This is not helpful.
If so, then next step is change VSCode settings
:
jupyter.logging.level": "verbose"
Then run VSCode command Developer: Reload Window
.
Now you should receive the error message.
For example, in my case I had the same error message as https://github.com/microsoft/vscode-jupyter/issues/15562#issuecomment-2062746960 from typing
and debugpy
:
...
16:56:43.988 [debug] [Debug] to kernel, mapped: {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"Python Kernel Debug Adapter","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true},"type":"request","seq":1}
16:56:44.013 [debug] KernelProcess error 11981: Traceback (most recent call last):
File "/opt/miniconda3/envs/pytorch/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/miniconda3/envs/pytorch/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/miniconda3/envs/pytorch/lib/python3.8/site-packages/debugpy/adapter/__main__.py", line 215, in <module>
__import__("debugpy")
File "/opt/miniconda3/envs/pytorch/lib/python3.8/site-packages/debugpy/adapter/../../debugpy/__init__.py", line 35, in <module>
from debugpy.public_api import * # noqa
File "/opt/miniconda3/envs/pytorch/lib/python3.8/site-packages/debugpy/adapter/../../debugpy/public_api.py", line 8, in <module>
import typing
File "/opt/miniconda3/envs/pytorch/lib/python3.8/site-packages/debugpy/adapter/../../typing.py", line 1359, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "/opt/miniconda3/envs/pytorch/lib/python3.8/site-packages/debugpy/adapter/../../typing.py", line 1007, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
16:56:54.185 [debug] [Debug] response: {"command":"initialize","request_seq":1,"seq":3,"success":false,"type":"response"}
...
Solution
As stated above, the solution is to uninstall typing
module/package:
pip uninstall typing
Explanation
I didn't fully understand why until found this explanation from https://stackoverflow.com/questions/55833509/attributeerror-type-object-callable-has-no-attribute-abc-registry#comment113222151_58067012
The typing package is only relevant on Python <= 3.5. Later versions include the typing module built-in, so you should uninstall it anyway. – WhyNotHugo
For Python versions:
-
<3.5
:typing
library, https://pypi.org/project/typing/ -
>=3.5
: Built-in, https://docs.python.org/3/library/typing.html
Hope this helps anyone else quickly come to a resolution and understanding!