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

"notebook controller is DISPOSED." when running a code cell during debug session #16185

Closed
paul-rogers opened this issue Oct 31, 2024 · 16 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-debugging

Comments

@paul-rogers
Copy link

Type: Bug

A notebook is open with a Python kernel. I was working on code for some hours. Nothing particularly special or large: just a around 20 cells, a few hundred lines of code, some Markdown and one MatPlotLib chart. Edited a Python cell containing a function declaration and ran it. Got a red error under the cell that says:

notebook controller is DISPOSED. 
View Jupyter log for further details.

The one thing I did wrong is that I edited the cell and ran it while a debug session was still active on that same cell. Usually this just redefines the function (which, obviously, is rather goofy on my part), but usually if I make this mistake all is fine when I end the debug session. This is the first time I've seen the above error.

There does not seem to be permanent damage. If I end the debug session, rerun the function definition cell and continue working, it seems that things are back to normal. So, this is some temporary glitch that can, apparently, be ignored.

The word "log" in the message above is a link. Clicking on that opens the log with the following:

20:39:20.614 [error] Error in cell execution [Error: notebook controller is DISPOSED
	at Object.createNotebookCellExecution (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:20981)
	at n.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29606)
	at n.getOrCreate (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29374)
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2955)
	at n.fromCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:3195)
	at l_.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2272)
	at d_.enqueue (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2603)
	at d_.queueCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2313)
	at p_.executeCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:8858)
	at /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94526
	at Array.map (<anonymous>)
	at n.executeQueuedCells (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94355)
	at async n.handleExecution (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:90678)
	at async Ob.$executeCells (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:24038)]
20:39:20.616 [error] Error in execution (get message for cell) [Error: notebook controller is DISPOSED
	at Object.createNotebookCellExecution (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:20981)
	at n.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29606)
	at n.getOrCreate (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29374)
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2955)
	at n.fromCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:3195)
	at l_.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2272)
	at d_.enqueue (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2603)
	at d_.queueCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2313)
	at p_.executeCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:8858)
	at /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94526
	at Array.map (<anonymous>)
	at n.executeQueuedCells (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94355)
	at async n.handleExecution (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:90678)
	at async Ob.$executeCells (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:24038)]

Extension version: 2024.10.0
VS Code version: Code 1.95.0 (912bb683695358a54ae0c670461738984cbb5b95, 2024-10-28T20:16:24.561Z)
OS version: Linux x64 6.8.0-47-generic
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (8 x 4429)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 1, 1, 1
Memory (System) 31.31GB (6.16GB free)
Process Argv --crash-reporter-id 5e232e7b-355a-468c-ac4a-02c300f898bd
Screen Reader no
VM 0%
DESKTOP_SESSION cinnamon
XDG_CURRENT_DESKTOP X-Cinnamon
XDG_SESSION_DESKTOP cinnamon
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
g316j359:31013175
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
wkspc-onlycs-t:31132770
nativeloc1:31134641
wkspc-ranged-t:31151552
cf971741:31144450
iacca1:31156133
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013

@DonJayamanne
Copy link
Contributor

Thank you for filing this issue and sorry you ran into this.
Are you able to repro this issue using the same steps?

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-debugging labels Oct 31, 2024
@paul-rogers
Copy link
Author

@DonJayamanne, this issue has happened only once. I have been using VS Code and Juypter regularly for over a year now and this is the first time that the problem has appeared. I did just update VS Code with the latest available, so perhaps something changed in the latest version?

@DonJayamanne
Copy link
Contributor

Thanks for the prompt response.

We haven't made any changes in this space, its more likely related to some other issue we're looking at.
Most likely a duplicate of #15716
Given that you cannot repro this and we have a similar issue, lets close this for now, as unfortunately theres' not much we can do at this point.
Please do not misunderstand me, i'm not saying I will not fix this, but without repro steps or the like, its difficult to resolve this.
Also its possible its just a dup of the issue mentioned earlier.

If however you do run into this, please do check the logs again & share the full logs (the contents in the logs before the error is crucial in this case), it would tell us whether the notebook was closed or a cell was deleted (visually the notebook may not be closed, however the notebook object may have been closed/disposed which results in such errors).

@DonJayamanne DonJayamanne added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 31, 2024
@DonJayamanne
Copy link
Contributor

If you run into this again, please feel free to create a new issue or ping here and we'll re-open this,
Most importantly, please do share the full logs.
thanks

@paul-rogers
Copy link
Author

@DonJayamanne, please tell me more about the logs you need.

Is it from the same Output window from which I copied the logs in this bug? If so, there were no other recent entries: the prior entries were from some hours before describing that I had started a debug session. (I know this because I used the timestamps to determine which parts of the logs to copy.)

Also, I had not closed the notebook (or any file for that matter) at the time of the issue, nor had I deleted a cell recently. The most recent cell action was likely the addition of a cell before going to edit the cell that raised the issue. The new cell was several below the cell where the error occurred.

It is understood that you need more info. Sorry the detailed logs were not enough. Let me know what you need in case it occurs again.

@paul-rogers
Copy link
Author

@DonJayamanne, FWIW here are the logs for a few operations before the one that had the above error. Looking closely, there were other instances of the "notebook controller is DISPOSED" error, but they did not result in an error message in the notebook itself.

(About 20 of the following)
15:37:52.797 [info] Disposing request as the cell (-1) was deleted ~/path/to/notebook.ipynb
(more lines line the following)
5:51:59.895 [info] Starting debugging with mode 1
15:53:32.459 [info] Ending debug session a4cf8db0-f4cc-43d6-b408-31c51fd06236
15:53:32.460 [info] Ending debug session a4cf8db0-f4cc-43d6-b408-31c51fd06236
15:53:32.517 [warn] Cell completed with errors [iu [Error]: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
	at n.execute (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:297:4958)] {
  ename: 'ValueError',
  evalue: 'omitted',
  traceback: [<omitted>]
}
15:53:42.132 [info] Starting debugging with mode 1
15:54:42.513 [info] Ending debug session 5ccf3070-9cce-4c6f-9110-209a7cc0d1db
15:54:45.272 [info] Ending debug session 5ccf3070-9cce-4c6f-9110-209a7cc0d1db
15:54:45.272 [info] Ending debug session 5ccf3070-9cce-4c6f-9110-209a7cc0d1db
17:07:14.642 [info] Starting debugging with mode 1
17:09:19.428 [info] Ending debug session 7b70f8b8-3fde-40c2-ba1a-c805b0dc769a
17:09:19.428 [info] Ending debug session 7b70f8b8-3fde-40c2-ba1a-c805b0dc769a
17:18:47.040 [info] Starting debugging with mode 1
17:20:04.912 [error] Error in cell execution [Error: notebook controller is DISPOSED
	at Object.createNotebookCellExecution (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:20981)
	at n.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29606)
	at n.getOrCreate (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29374)
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2955)
	at n.fromCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:3195)
	at l_.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2272)
	at d_.enqueue (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2603)
	at d_.queueCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2313)
	at p_.executeCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:8858)
	at /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94526
	at Array.map (<anonymous>)
	at n.executeQueuedCells (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94355)
	at async n.handleExecution (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:90678)
	at async Ob.$executeCells (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:24038)]
17:20:04.913 [error] Error in execution (get message for cell) [Error: notebook controller is DISPOSED
	at Object.createNotebookCellExecution (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:20981)
	at n.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29606)
	at n.getOrCreate (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29374)
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2955)
	at n.fromCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:3195)
	at l_.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:296:2272)
	at d_.enqueue (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2603)
	at d_.queueCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:2313)
	at p_.executeCell (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:298:8858)
	at /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94526
	at Array.map (<anonymous>)
	at n.executeQueuedCells (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:94355)
	at async n.handleExecution (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:90678)
	at async Ob.$executeCells (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:24038)]
17:20:11.984 [info] Ending debug session f99dad72-e64d-4190-b02f-6b670dc9c0e7
17:20:11.985 [info] Ending debug session f99dad72-e64d-4190-b02f-6b670dc9c0e7
17:20:38.619 [info] Starting debugging with mode 1
17:21:08.381 [info] Ending debug session a2c0bb53-c7dd-441c-adc5-28e6da61d886
17:21:10.400 [info] Ending debug session a2c0bb53-c7dd-441c-adc5-28e6da61d886
17:21:10.400 [info] Ending debug session a2c0bb53-c7dd-441c-adc5-28e6da61d886
20:31:08.269 [warn] Cell completed with errors [iu [Error]: Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
	at n.execute (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:297:4958)] {
  ename: 'UFuncTypeError',
  evalue: "omitted'",
  traceback: [<omitted>]
}
20:32:08.062 [warn] Cell completed with errors [iu [Error]: 'str' object has no attribute 'trim'
	at n.execute (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:297:4958)] {
  ename: 'AttributeError',
  evalue: "omitted",
  traceback: [<omitted>]
}
20:34:12.930 [info] Starting debugging with mode 1
20:34:49.246 [info] Ending debug session db902757-add9-4d10-8b36-f87d7f3d1c4b
20:34:51.751 [info] Ending debug session db902757-add9-4d10-8b36-f87d7f3d1c4b
20:34:51.751 [info] Ending debug session db902757-add9-4d10-8b36-f87d7f3d1c4b
20:38:06.151 [info] Starting debugging with mode 1
20:39:20.614 [error] Error in cell execution [Error: notebook controller is DISPOSED

The last line above is the one reported earlier.

@DonJayamanne
Copy link
Contributor

Please can you re-load VS Code and replicate the issue and share the full log (start to end).

@DonJayamanne DonJayamanne reopened this Nov 1, 2024
@DonJayamanne
Copy link
Contributor

Please could you enable logging as follows:

  • Open settings & go into Jupyter->Logging
  • Change the value to trace
  • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel (use the command Jupyter: Show Output to get to the logs).

@DonJayamanne DonJayamanne removed the *duplicate Issue identified as a duplicate of another issue(s) label Nov 1, 2024
@paul-rogers
Copy link
Author

paul-rogers commented Nov 1, 2024

Thanks for the info. Your timing was perfect: the problem just happened again. I believe I may have tracked down more of the specifics for you.

VS Code had been idle for some hours. I sat down and started editing some code, then ran a cell that referenced that code. The error again appeared, in red, below the cell:

notebook controller is DISPOSED. 

In the logs (with info setting for now):

21:11:05.733 [info] Too many pending requests 1 for kernel 1a6ae5aa-2bea-43c5-b790-ce1eb53017ab, waiting for it to be ready.
21:30:03.893 [error] Error in cell execution [Error: notebook controller is DISPOSED
	at Object.createNotebookCellExecution (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:20981)
	at n.create (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:115:29606)
...

This time the cause is that my edit introduced an (unintended) infinite loop. So, when I ran cell A, Python went into a loop. However, expecting that the code would execute immediately, I also ran cell B. That is when the above error occurred.

The possible parallel with the previous case is that I was debugging, stopped at a break point, when I recognized an issue, changed the code, and ran the cell containing the function in question. Thus, I asked Python to run a cell while a debug session was active.

Indeed, I can now reliably reproduce the error by again executing my code with the bug that causes the infinite loop (cell "A" above), then, while running, execute cell "B". But, only when another condition has also occurred, as explained below.

Next, I changed the log setting as requested, restarted VS Code and repeated the above scenario. This time, no error.

So, that brings us to one additional factor. Issue VS Code Issue #24364 describes my attempts to deal with an upgraded Python interpreter. In both sessions where the failure occurred, I configured a Python virtual environment by hand, then chose that environment in Jupyter. What reminded me of this was that, in the prior session (alas, now gone, so I can't copy the log lines), I saw Jupyter logging messages that it had detected the change in kernel.

To test this, I again went though the steps in VS Code Issue #24364 to select the recommended interpreter (so that the interpreter changes), then to manually configure my virtual environment. As described in that other issue, Jupyter "lost" the kernel when I switch to the recommended one, then "remembered" the kernel when I switched back to my virtual environment. I then reran the required code cells in my notebook, including the one with the buggy infinite loop (cell "A"). As before, with that cell running, I ran cell "B" and again got the notebook controller is DISPOSED. error. Thus, the error concerns:

  • A change to the interpreter
  • Running a code cell while the interpreter is running (possibly in a debug session)

Logs:

Visual Studio Code (1.95.0, undefined, desktop)
Jupyter Extension Version: 2024.10.0.
Python Extension Version: 2024.16.1.
Pylance Extension Version: 2024.10.1.
Platform: linux (x64).
...
(entries for the attempt to reproduce that did not trigger the error)
...
21:51:50.858 [trace] Python API env change detected, update => '/home/~/pyenv/3.12/bin/python'
21:51:50.858 [debug] Start refreshing Kernel Picker (1730436710858)
21:51:50.859 [debug] End refreshing Kernel Picker (1730436710858)
21:51:55.002 [debug] Handle Execution of Cells 4 for ~/omitted.ipynb
21:51:55.003 [trace] Execute Notebook ~/omitted.ipynb. Step 1
21:51:55.003 [trace] Connect to Kernel ~/omitted.ipynb. Step 2
21:51:55.008 [trace] Connected to Kernel ~/omitted.ipynb. Step 3
21:51:55.008 [trace] executeCell 4. Step 4
21:51:55.008 [trace] Cell Index:4 sent to kernel
21:51:55.011 [trace] Start cell 4 execution @ 1730436715011 (clear output)
21:51:55.011 [debug] Kernel acknowledged execution of cell 4 @ 1730436715011
21:51:55.019 [trace] Cell 4 completed in 0.006s (start: 1730436715011, end: 1730436715017)
21:51:55.019 [trace] Cell 4 executed successfully
21:52:01.337 [debug] Handle Execution of Cells 22 for ~/omitted.ipynb
21:52:01.338 [trace] Execute Notebook ~/omitted.ipynb. Step 1
21:52:01.338 [trace] Connect to Kernel ~/omitted.ipynb. Step 2
21:52:01.339 [trace] Connected to Kernel ~omitted.ipynb. Step 3
21:52:01.339 [trace] executeCell 22. Step 4
21:52:01.339 [trace] Cell Index:22 sent to kernel
21:52:01.362 [trace] Start cell 22 execution @ 1730436721362 (clear output)
21:52:01.362 [debug] Kernel acknowledged execution of cell 22 @ 1730436721362
21:52:05.672 [debug] Handle Execution of Cells 23 for ~/omitted.ipynb
21:52:05.672 [trace] Execute Notebook ~/omitted.ipynb. Step 1
21:52:05.672 [trace] Connect to Kernel ~/omitted.ipynb. Step 2
21:52:05.672 [trace] Connected to Kernel ~/omitted.ipynb. Step 3
21:52:05.673 [trace] executeCell 23. Step 4
21:52:05.673 [error] Error in cell execution [Error: notebook controller is DISPOSED

The ~/omitted.ipynb above is just the obfuscated path to my notebook.

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Nov 1, 2024

@paul-rogers Please can you share the full logs.
We're missing information about

  • Selecting a kernel
  • Starting a kernel, etc.. there's a lot thats missing.
    Also please can you run a simple notebook with just one cell to try to keep things simpler.

Also, please can you add the following setting into your settings folder

"jupyter.enableKernelCompletions": false

Optionally you can just do this via the settings ui
(once done please reload VS Code)
Image

@paul-rogers
Copy link
Author

As requested, here is a session with full logs and new notebook.

I was earlier wrestling with getting the Python extension to find my virtual environment. After realizing that the documentation was incomplete, and taking the necessary steps, my virtual environment now does appear in the Python: Select Interpreter list. So, the part of the description about Select Kernel not finding my environment is moot. This issue is about the DISPOSED error, the interpreter issue was a confounding factor.

Also, as requested in another issue, I did update the Python extension to the newest version, so the following description is with the latest version.

To start, let's just set up the kernel:

  • Created a new, empty directory to serve as a project.
  • Opened that directory in VS Code.
  • Created an empty notebook.
  • Restarted VS Code to clear logs and put things in a sane state.
  • Selected my virtual environment with Python: Select Interpreter.
  • In the empty notebook, clicked Select Kernel, then Python Environments... and selected by virtual environment.

Logs thus far. The contents seem to contain many errors that I did not see in sessions reported above.

Visual Studio Code (1.95.0, undefined, desktop)
Jupyter Extension Version: 2024.10.0.
Python Extension Version: 2024.18.0.
Pylance Extension Version: 2024.10.1.
Platform: linux (x64).
Temp Storage folder ~/.config/Code/User/globalStorage/ms-toolsai.jupyter/version-2024.10.0
Workspace folder ~/testproj, Home = /home/paul
11:10:16.409 [debug] Start refreshing Kernel Picker (1730484616409)
11:10:17.473 [trace] Kernel Spec for 'Python 3 (ipykernel)' (~/.local/share/jupyter/kernels/python3/kernel.json) is hidden. (isDefaultKernelSpec = true, language = python, registrationInfo = undefined)
11:10:17.474 [debug] Get Custom Env Variables, Class name = Em, completed in 1065ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
11:10:17.474 [debug] Jupyter Paths /kernels: 
11:10:17.474 [debug] Kernel Spec Root Paths, /usr/share/jupyter/kernels, /usr/local/share/jupyter/kernels, ~/.local/share/jupyter/kernels
11:10:18.096 [debug] End refreshing Kernel Picker (1730484616409)
11:10:18.101 [trace] Python API env change detected, add => 'pyenv/3.12-old/bin/python'
11:10:18.102 [trace] Search for KernelSpecs in Interpreter /pyenv/3.12-old/bin/python
11:10:18.102 [debug] Start refreshing Kernel Picker (1730484618102)
11:10:18.109 [debug] End refreshing Kernel Picker (1730484618102)
11:10:18.111 [trace] Python API env change detected, add => '/home/~/pyenv/3.12/bin/python'
11:10:18.111 [trace] Search for KernelSpecs in Interpreter ~/pyenv/3.12/bin/python
11:10:18.112 [debug] Start refreshing Kernel Picker (1730484618112)
11:10:18.118 [trace] Python API env change detected, add => 'pyenv/3.12/bin/python'
11:10:18.119 [trace] Search for KernelSpecs in Interpreter /pyenv/3.12/bin/python
11:10:18.140 [trace] Python API env change detected, add => '/home/~/pyenv/3.12-old/bin/python'
11:10:18.140 [trace] Search for KernelSpecs in Interpreter ~/pyenv/3.12-old/bin/python
11:10:18.151 [trace] Hiding default KernelSpec /python for interpreter ~/pyenv/3.12/bin/python (KernelSpec file ~/pyenv/3.12/share/jupyter/kernels/python3/kernel.json)
11:10:18.165 [trace] Hiding default KernelSpec /python for interpreter ~/pyenv/3.12-old/bin/python (KernelSpec file ~/pyenv/3.12-old/share/jupyter/kernels/python3/kernel.json)
11:10:18.166 [debug] End refreshing Kernel Picker (1730484618112)
11:10:18.168 [trace] Python API env change detected, add => '/bin/python3'
11:10:18.169 [trace] Search for KernelSpecs in Interpreter /bin/python3
11:10:18.169 [debug] Start refreshing Kernel Picker (1730484618169)
11:10:18.172 [debug] End refreshing Kernel Picker (1730484618169)
11:10:18.174 [trace] Python API env change detected, add => '/usr/bin/python3'
11:10:18.174 [trace] Search for KernelSpecs in Interpreter /usr/bin/python3
11:10:18.174 [debug] Start refreshing Kernel Picker (1730484618174)
11:10:18.177 [debug] End refreshing Kernel Picker (1730484618174)
11:10:18.180 [trace] Python API env change detected, add => '/home/~/anaconda3/bin/python'
11:10:18.180 [trace] Search for KernelSpecs in Interpreter ~/anaconda3/bin/python
11:10:18.180 [debug] Start refreshing Kernel Picker (1730484618180)
11:10:18.185 [trace] Hiding default KernelSpec ~/anaconda3/bin/python for interpreter ~/anaconda3/bin/python (KernelSpec file ~/anaconda3/share/jupyter/kernels/python3/kernel.json)
11:10:18.186 [debug] End refreshing Kernel Picker (1730484618180)
11:10:18.506 [trace] Conda file is /home/~/anaconda3/bin/conda
11:10:34.774 [trace] Python API env change detected, update => 'pyenv/3.12/bin/python'
11:10:34.774 [trace] Search for KernelSpecs in Interpreter /pyenv/3.12/bin/python
11:10:34.775 [debug] Start refreshing Kernel Picker (1730484634775)
11:10:34.778 [trace] Hiding default KernelSpec /python for interpreter ~/pyenv/3.12/bin/python (KernelSpec file ~/pyenv/3.12/share/jupyter/kernels/python3/kernel.json)
11:10:34.780 [debug] End refreshing Kernel Picker (1730484634775)
11:10:34.791 [debug] Get Custom Env Variables, Class name = Em, completed in 1ms, has a truthy return value, Arg 1: "~/testproj", Arg 2: "RunPythonCode"
11:10:34.829 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a./pyenv/3.12/python./pyenv/3.12/python.-m#ipykernel_launcher
11:10:34.829 [debug] start the kernel, options.disableUI=true for ~/testproj/Test.ipynb
11:10:34.880 [trace] Registering commtarget jupyter.widget
11:10:34.882 [debug] Controller selection change completed
11:10:34.882 [info] Starting Kernel (Python Path: /pyenv/3.12/bin/python, Venv, 3.12.3) for '~/testproj/Test.ipynb' (disableUI=true)
11:10:34.883 [trace] Creating raw notebook for resource '~/testproj/Test.ipynb'
11:10:34.895 [debug] Get Custom Env Variables, Class name = Em, completed in 2ms, has a truthy return value, Arg 1: "~/testproj/Test.ipynb", Arg 2: "RunPythonCode"
11:10:34.908 [debug] Launching kernel .jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a./pyenv/3.12/python./pyenv/3.12/python.-m#ipykernel_launcher for ~/testproj/Test.ipynb in //home/~/testproj with ports 9001, 9000, 9004, 9002, 9003
11:10:34.913 [debug] Got env vars from Python Ext in 123ms for /pyenv/3.12/bin/python, with env var count 60.
11:10:34.913 [trace] Prepend PATH with python bin for /pyenv/3.12/bin/python
11:10:34.914 [debug] Getting activated env variables, Class name = Id, completed in 125ms, has a truthy return value, Arg 1: "~/testproj", Arg 2: "pyenv/3.12/bin/python", Arg 3: undefined
11:10:34.922 [info] Process Execution: /pyenv/3.12/bin/python -m pip list
11:10:34.926 [debug] Got env vars from Python Ext in 33ms for /pyenv/3.12/bin/python, with env var count 60.
11:10:34.927 [trace] Prepend PATH with python bin for /pyenv/3.12/bin/python
11:10:34.927 [debug] Getting activated env variables, Class name = Id, completed in 34ms, has a truthy return value, Arg 1: "~/testproj/Test.ipynb", Arg 2: "pyenv/3.12/bin/python", Arg 3: undefined
11:10:34.933 [info] Process Execution: /pyenv/3.12/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
11:10:34.940 [info] Process Execution: /pyenv/3.12/bin/python -m ipykernel_launcher --f=/home/~/.local/share/jupyter/runtime/kernel-v320def125bc51ce01dfbf4e676f72901e2cc73d81.json
    > cwd: //home/~/testproj
11:10:34.941 [debug] Kernel process undefined.
11:10:34.945 [error] Kernel died [Error: spawn /pyenv/3.12/bin/python ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /pyenv/3.12/bin/python',
  path: '/pyenv/3.12/bin/python',
  spawnargs: [
    '-m',
    'ipykernel_launcher',
    '--f=/home/~/.local/share/jupyter/runtime/kernel-v320def125bc51ce01dfbf4e676f72901e2cc73d81.json'
  ]
} 
11:10:34.945 [error] Disposing kernel process due to an error [Error: spawn /pyenv/3.12/bin/python ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /pyenv/3.12/bin/python',
  path: '/pyenv/3.12/bin/python',
  spawnargs: [
    '-m',
    'ipykernel_launcher',
    '--f=/home/~/.local/share/jupyter/runtime/kernel-v320def125bc51ce01dfbf4e676f72901e2cc73d81.json'
  ]
}
11:10:34.945 [error] 
11:10:34.945 [debug] Dispose Kernel process undefined.
11:10:34.948 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
11:10:34.948 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
11:10:34.949 [warn] Failed to shutdown kernel, .jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a./pyenv/3.12/python./pyenv/3.12/python.-m#ipykernel_launcher [TypeError: Cannot read properties of undefined (reading 'dispose')
	at U_.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:13745)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async W_.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:304:22578)]
11:10:34.949 [trace] failed to create IJupyterKernelConnectionSession in kernel, UI Disabled = true [qd [Error]: 
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:98:4480)
	at new yl (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:181:16388)
	at new qd (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:270:26482)
	at Dy.launch (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:301:4)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: spawn /pyenv/3.12/bin/python ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  category: 'unknown',
  isJupyterError: true,
  originalException: [Error: spawn /pyenv/3.12/bin/python ENOENT
  	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
  	at onErrorNT (node:internal/child_process:484:16)
  	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn /pyenv/3.12/bin/python',
    path: '/pyenv/3.12/bin/python',
    spawnargs: [
      '-m',
      'ipykernel_launcher',
      '--f=/home/~/.local/share/jupyter/runtime/kernel-v320def125bc51ce01dfbf4e676f72901e2cc73d81.json'
    ]
  },
  kernelConnectionMetadata: n {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: ld {
      specFile: '/home/~/.config/Code/User/globalStorage/ms-toolsai.jupyter/version-2024.10.0/jupyter/kernels/python3123jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a/kernel.json',
      interpreterPath: '/pyenv/3.12/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'python3123jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '3.12',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: { id: 'pyenv/3.12/bin/python', uri: [Zo] },
    id: '.jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a./pyenv/3.12/python./pyenv/3.12/python.-m#ipykernel_launcher'
  },
  stdErr: '\n\n'
}
11:10:34.950 [warn] Error occurred while trying to start the kernel, options.disableUI=true [qd [Error]: 
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:98:4480)
	at new yl (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:181:16388)
	at new qd (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:270:26482)
	at Dy.launch (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/dist/extension.node.js:301:4)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: spawn /pyenv/3.12/bin/python ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  category: 'unknown',
  isJupyterError: true,
  originalException: [Error: spawn /pyenv/3.12/bin/python ENOENT
  	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
  	at onErrorNT (node:internal/child_process:484:16)
  	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn /pyenv/3.12/bin/python',
    path: '/pyenv/3.12/bin/python',
    spawnargs: [
      '-m',
      'ipykernel_launcher',
      '--f=/home/~/.local/share/jupyter/runtime/kernel-v320def125bc51ce01dfbf4e676f72901e2cc73d81.json'
    ]
  },
  kernelConnectionMetadata: n {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: ld {
      specFile: '/home/~/.config/Code/User/globalStorage/ms-toolsai.jupyter/version-2024.10.0/jupyter/kernels/python3123jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a/kernel.json',
      interpreterPath: '/pyenv/3.12/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'python3123jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '3.12',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: { id: 'pyenv/3.12/bin/python', uri: [Zo] },
    id: '.jvsc74a57bd0da0c5df3dd3647ad5d4882cd2acf3882f3baa2bd3e4126fcd690f3b43894195a./pyenv/3.12/python./pyenv/3.12/python.-m#ipykernel_launcher'
  },
  stdErr: '\n\n'
}
11:10:34.959 [debug] Disposed Kernel process undefined.

I do not know what all the above means. But, in case it matters, my list of Python interpreters is currently littered with duplicates due to my efforts to resolve another issue:

Image

@paul-rogers

This comment has been minimized.

@paul-rogers

This comment has been minimized.

@paul-rogers
Copy link
Author

Now we can move onto reproducing the actual DISPOSED error. As it turns out, I cannot reproduce it once I stopped using the Venv Folders setting to configure my virtual environment, and instead used Venv Path. In a new Notebook:

  • Cell 1:
def loop():
    while True:
        pass
  • Execute this Cell 1 to define the function.
  • Cell 2:
loop()
  • Execute Cell 2 to keep Python spinning.
  • Modify Cell 1, add x = 10 inside the function.
  • Execute Cell 1.

The logs indicate no problem. Recall that this is simplified version of the scenario described in this bug. With a properly-configured interpreter, the DISPOSED error does not occur.

I don't have the time to repeat this using the broken Venv Folders setting, but I'd bet that the problem is due to the use of that setting.

@paul-rogers
Copy link
Author

To see if the use of Venv Path fixes the original problem, I reopened my project. The Jupyter logs contained no error, but it does contain the following odd line:

12:32:22.767 [debug] Refreshed Environments
12:32:22.772 [trace] Python API env change detected, update => '/home/~/pyenv/3.12/bin/python'

What is odd is that /home/~/pyenv/... is not a valid Linux path. A valid path (before expansion) would be ~/pyenv/... or (after expansion) /home/paul/pyenv/.... Maybe this is just a cosmetic issue: the rest of the logs look clean and things do work.

I then recreated the infinite loop mentioned before. (The code had since been fixed.) I then recreated the scenario described above. No errors appeared in the notebook or in the logs.

My conclusion is that the DISPOSED error was a side effect of the evil Venv Folders setting. As I suggested in the other issue: do not use this setting. Use Venv Path instead and life will be much easier.

@DonJayamanne
Copy link
Contributor

Than you for getting back, closing this issue as its been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-debugging
Projects
None yet
Development

No branches or pull requests

2 participants