kernel keeps dying in jupyter notebook
Asked Answered
N

7

34

Whenever I start jupyter notebook and create a new python 3 notebook I get an error message saying kernel has died. I have tried deleting and installing ipython, python3.6.5, and jupyter notebook but I still get the error message.

My cmd screen is as follows:-

[I 06:46:36.432 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
WARNING:root:kernel 0d0442a9-c92f-46e6-acdd-08ca0a18c5f2 restarted
Traceback (most recent call last):

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\ipykernel\connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\IPython\__init__.py", line 55, in <module>
    from .terminal.embed import embed

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\IPython\terminal\embed.py", line 17, in <module>
    from IPython.terminal.ipapp import load_default_config

  File "c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages\IPython\terminal\ipapp.py", line 34, in <module>
    from IPython.extensions.storemagic import StoreMagics

**ModuleNotFoundError: No module named 'IPython.extensions'**

[W 06:46:39.450 NotebookApp] KernelRestarter: restart failed

[W 06:46:39.450 NotebookApp] Kernel 0d0442a9-c92f-46e6-acdd-08ca0a18c5f2 died, removing from map.

ERROR:root:kernel 0d0442a9-c92f-46e6-acdd-08ca0a18c5f2 restarted failed!
[W 06:46:39.461 NotebookApp] 410 DELETE /api/sessions/67987236-8755-433a-afcb-e052ccbf65b9 (::1): Kernel deleted before session

**[W 06:46:39.461 NotebookApp] Kernel deleted before session**

[W 06:46:39.461 NotebookApp] 410 DELETE /api/sessions/67987236-8755-433a-afcb-e052ccbf65b9 (::1) 1.00ms 

referer=http://localhost:8888/notebooks/Untitled5.ipynb?kernel_name=python3## Heading ##
Neb answered 10/6, 2018 at 16:15 Comment(3)
It’s possible something is interfering with the port you are trying to use.Hernadez
@data83 I am sure nothing is interfering with the port because jupyter notebook works fine as a text editor problem only occurs when I create a python 3 notebook, the python 3 kernel dies.Neb
@KlausD. added the error output as text see now if you can help me.Neb
S
17

Determining why jupyter notebook kernel dies can be daunting sometimes. When kernel dies as a result of library issues, you might not get any feedback as to what is causing it. Try running the code that is causing the kernel to die in a terminal or in ipython. One common issue I have identified is the use of SSE4.1 in later versions of tensorflow, which gives this error: TensorFlow library was compiled to use SSE4.1 instructions, but these aren't available on your machine. Aborted (core dumped). This will cause the kernel to die if you are using tensorflow in your code and not display any error in notebook. If this is the case, uninstall tensorflow and install with conda: conda install tensorflow==1.12.0, for instance.

Shinny answered 10/12, 2019 at 2:56 Comment(0)
B
6

You can try reinstall Jupyter,

pip uninstall jupyter
pip install jupyter

and try again, which works in my case. I had this problem when I upgrade to Ubuntu 18.04.

Also check this thread. https://github.com/jupyter/notebook/issues/1892

Basketball answered 1/9, 2018 at 23:38 Comment(0)
A
6

Not the exact same issue as yours, but I found my kernel kept dying when I used the

exit()

command in one of my class methods. Removing this exit() command stopped my kernel from dying.

Astrahan answered 10/1, 2021 at 15:17 Comment(0)
H
3

Please try to uninstall all of:

  • ipykernel
  • ipython
  • jupyter_client
  • jupyter_core
  • traitlets
  • ipython_genutils

And then install again.

it works for me after trying many others solutions. Actually, the problem of conflicting libraries causes this issue.

Hetero answered 20/12, 2021 at 5:43 Comment(2)
"Have you tried to turn it off and on again?" :-) This cannot be a good solution though...Worrisome
But it worked for me!Juieta
W
1

If there are a backup of kernels, this can happen as well. I shutdown the server and it told me shutting down 4 kernels. Apparently I had some old runaway kernels. When I restarted the server, a single new fresh kernel was created and I was back in business.

Workingman answered 11/3, 2020 at 15:42 Comment(0)
F
0

Well, I am having the same issue but when I use matplotlib and try to plot libraries, I had the same issue with spyder. Guess trying to update libraries should solve it. Using Jupyter via Anaconda, could be a possible anaconda issue as well.

Formfitting answered 30/11, 2021 at 0:56 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Patron
D
0

Run the following code before running your code:

import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
Dihedron answered 17/6 at 21:40 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Patron

© 2022 - 2024 — McMap. All rights reserved.