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.

Cannot restart kernel after kernel dies

See original GitHub issue

Environment data

  • VS Code version: Version: 1.59.0 Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8 Date: 2021-08-04T23:14:40.191Z (1 wk ago) Electron: 13.1.7 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 20.6.0

  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.1195043623

  • Python Extension version (available under the Extensions sidebar): v2021.8.1105858891

  • OS (Windows | Mac | Linux distro) and version: MacOS 11.5.1

  • Python and/or Anaconda version: Python 3.9.5 (also tested with 3.9.6, 3.8.10 and 3.7 - same issue)

  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): tested with conda and venv

  • Jupyter server running: The problem happens both locally and in a remote setup (remote VM)

Expected behaviour

I need to restart my kernel after a pip install. I need to execute the following code and restart my kernel, without loosing connectivity to it.

import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 

Actual behaviour

After executing the app.kernel.do_shutdown(True) I receive the following message:

Error: Session cannot generate requests
Error: Session cannot generate requests
at w.executeCodeCell (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:325139)
at w.execute (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:324460)
at w.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:320276)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async t.CellExecutionQueue.executeQueuedCells (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334803)
at async t.CellExecutionQueue.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334343)

If I restart the kernel using the “Restart” button from the UI interface, I still receive the same message. I can only get my environment running again if I select another kernel and then select the original kernel again.

Steps to reproduce:

  1. Create an empty notebook and open in VScode (with the extension enabled).
  2. Enable the kernel
  3. On the first cell type a print('Hello World') to make sure it is working
  4. On the second cell execute the following code:
import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 
  1. Include a new cell with a print('Hello world') to see the error message.

Logs

Please see the attached files. kernel_restart_OK.txt cell_exec_FAIL.txt requirements.txt

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Wang-Chbocommented, Sep 10, 2021

I have the same issue. If I run the code with Jupyter v2021.8.2041215044,when I run this demo(https://tensorflow.google.cn/text/tutorials/transformer?hl=zh_cn), Error: Session cannot generate requests will rise. So I use an old version Jupyter, and this issue will disappear

1reaction
DonJayamannecommented, Sep 7, 2021

@momt99

Please could you file a separate issue. looks like you have some code in the cell that’s causing the kernel to crash/die.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Jupyter notebook - Dead Kernel - Stack Overflow
The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able...
Read more >
Recovered from a dead kernel in Jupyter - Cognitive Class Labs
Once you've closed the other notebooks, you can restart your dead kernel by going to "Kernel" > "Restart" within Jupyter.
Read more >
The kernel appears to have died. It will restart ... - YouTube
In this video, I'll show you how to fix the error message "The kernel appears ... ... Your browser can't play this video....
Read more >
Kernel Died error post installing tensorflow - Apple Developer
I m facing huge problem with Jupyter notebook post installing tensorflow as the kernel keeps dying and I have literally tried solution in...
Read more >
The Kernel appears to have died. It will ... - Google Groups
After MKL update: $ jupyter-kernelspec list. Available kernels: python2 ... to allocate this much memory - only that it can not allocate more...
Read more >

github_iconTop Related Medium Post

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