Repeated "Kernel died, restarting" forever - python

When I attempt to run
$ jupyter qtconsole
The console shows up, with the message
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Which continues.
Trying $ jupyter qtconsole --debug didn't print anything else, and neither has adding
c.Application.log_level = 0
c.Session.debug = True
into $USERHOME/.jupyter/jupyter_qtconsole_config.py
Also, I found nothing in $USERHOME/.ipython/profile_default/log/ and the other directories around there.
Nothing has changed in my configuration since last time I started up jupyter-qtconsole.
How can I at least find out what's going wrong with the kernel? Surely there is some option in Jupyter to get the kernel's STDERR output to see what exception had upset it?

Run this-
conda remove ipykernel ipython jupyter_client jupyter_core traitlets ipython_genutils
conda clean -tipsy
conda install ipykernel ipython jupyter_client jupyter_core traitlets ipython_genutils
jupyter notebook

I run
spyder --show-console
when I receive in spyder
Kernel died, restarting
I see message in console
Intel MKL FATAL ERROR: Cannot load libmkl_p4m.so or libmkl_p4.so.
It was helpfull for me
conda install nomkl numpy scipy scikit-learn numexpr
conda remove mkl mkl-service

Check the log. I had the same problem and my log shows no module named ipykernel_launcher. So, I just pip install ipykernel and solve the problem.

I tried several solutions and finally i found one which really works.
You just have to add an exception to your antivirus and/or firewall.
I currently use Avast, so adding an exception concerning the folder where i installed Anaconda and the virtual environments solved the problem and now Spyder works as a charm.

Encountered this problem when try to use pandas to read data in clipboard, tried many times in Spyder editor which is from the Anaconda3. I have also tried to solve the problem by updating the Spyder and other Anaconda3 packages, but failed to solve it.
Finally, without using the Anaconda3, in another PC install python 3.5.3, then
pip install pandas, the error dismissed.

Given that the kernel is another process, I was able to catch the command line it was started with, using Process Explorer. The command line was
$ pythonw -m ipykernel -f "$USERHOME/AppData/Roaming/jupyter/runtime/kernel-2744.json"
Then, I just launched python and tried importing ipykernel, and got this:
$ python
Python 2.7.12 [...] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipykernel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Programs\Python2712\lib\site-packages\ipykernel\__init__.py", line 2,
in <module>
from .connect import *
File "C:\Programs\Python2712\lib\site-packages\ipykernel\connect.py", line 13,
in <module>
from IPython.core.profiledir import ProfileDir
File "C:\Programs\Python2712\lib\site-packages\IPython\__init__.py", line 48,
in <module>
from .core.application import Application
File "C:\Programs\Python2712\lib\site-packages\IPython\core\application.py", l
ine 25, in <module>
from IPython.core import release, crashhandler
File "C:\Programs\Python2712\lib\site-packages\IPython\core\crashhandler.py",
line 28, in <module>
from IPython.core import ultratb
File "C:\Programs\Python2712\lib\site-packages\IPython\core\ultratb.py", line
119, in <module>
from IPython.core import debugger
File "C:\Programs\Python2712\lib\site-packages\IPython\core\debugger.py", line
36, in <module>
from IPython.utils import PyColorize, ulinecache
File "C:\Programs\Python2712\lib\site-packages\IPython\utils\PyColorize.py", l
ine 55, in <module>
from IPython.utils.py3compat import PY3
File "C:\Programs\Python2712\lib\site-packages\IPython\utils\py3compat.py", li
ne 296, in <module>
PYPY = platform.python_implementation() == "PyPy"
AttributeError: 'module' object has no attribute 'python_implementation'
>>> exit()
And this quickly led to the problem, as described in this answer, being that the directory I was trying to start jupyter qtconsole in had a subdirectory called platform, which conflicted with the name of a module.
While this fixes this specific instance of "Kernel died, restarting", the general question still stands: how to make sure that the stacktrace, like the one above, is reported to the user of Jupyter console, instead of the kernel dying silently?

If the working directory where jupyter qtconsole is launched from contains some special characters, the "Kernel died, restarting" error may occur repeatedly.
For me, I had launched jupyter qtconsole from a working directory whose path contained spaces and ampersands (&). When I change directory to root drive (D:/ in my case) the problem goes away.

I'm having the similar problem when I run import Tensorflow as tf.
After downgrading to the Tensorflow 1.5 version, the problem was resolved.
Try uninstalling TensorFlow:
pip uninstall tensorflow
and then reinstalling 1.5:
pip install tensorflow==1.5

Jupyter_client and jupyter_core releases have been made available (and contain the fix for this issue), would you mind trying the following:
1. pip install jupyter_client --upgrade - this should replace your modified jupyter_client package with release 5.3.4 and install the updated version of jupyter_core (4.6.0)
2. If you find that jupyter_core is NOT 4.6.0 - please try pip install jupyter_core --upgrade.
Check out the thread here: https://github.com/jupyter/notebook/issues/4907

I had the same problem. I deleted the content at C:\Users\youruser\AppData\Roaming\jupyter\runtime then runs again jupyter notebook. it was helpful for me.

minimize your batch_size it's working for me
i tried updating ipykernel and i updated my numpy nothing seems to work for. just minimized my batch it's working

In my case, Updating Numpy, reinstall jupyter, reinstall anaconda, install module with conda all are not works for me...
I just Delete CUDNN folder, and that's it...

Related

ImportError: DLL load failed while importing shell

Importing winshell (version 0.6) causes the following error:
>>> import winshell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python39\lib\site-packages\winshell.py", line 32, in <module>
from win32com.shell import shell, shellcon
ImportError: DLL load failed while importing shell: The specified procedure could not be found.
I finally managed to get Anaconda to start working by executing the line:
pip install pywin32==300
I had to do it twice, because the first time it went for 301, not 300. The second time then dropped it to 300. This was from the Anaconda for Windows installer downloaded just two days ago from the Anaconda website and doing a "clean install"!
What a fiasco!
Until that point, NOTHING really worked. Almost every important command within Anaconda would fail with the Win32com error, and Navigator would not even start. Apparently the latest version of pywin32 is 304, but it doesn't work either. Is anyone looking into this? For a newbie like me, this is a very bad look for Anaconda as a tool! I was on the brink of simply giving up when I literally stumbled onto this thread.
Note that it has been MONTHS between my post and the one before mine. I'd say that this has probably caused a lot of people to simply give up (assuming that there are many who actually try to install this on Windows per month, that is).
I've had similar in the past,was about to give up on Anaconda.
Here's the solution
Apparently the wrong version of pywin32 gets installed.
I had the installed version 301 and after downgrading to 228 with pip install --upgrade pywin32==228 everything just started working.
Try pip install --upgrade pywin32==228
This should resolve the issue
Version 300 of pywin32 solved this issue for me! Check this other question for more info
Had the same issue with Conda and librosa in Python 3.9.
Librosa references from win32com.shell import shellcon,shell, which was causing the same error you received.
Installing pywin32 via conda fixed the error for me:
conda install -c conda-forge librosa
I ran into this issue when trying to get Anaconda to run at all on a new installation. I followed Alex T's recommendation to install version 300 of pywin32. Like him, I had to run it twice because it first installed version 302 for some reason. After running it the second time I can now run conda commands in that environment
pip install pywin32==300
My simple solution is to install an Older version of Anaconda. This worked perfectly for me. I installed Anaconda3-2021.11-Windows-x86 version.
The Newer Version of Anaconda has some problems with pywin32. I first tried the command :
pip install --upgrade pywin32==228
but It didn't workd for me. Installing an older version finally solved the problem of anaconda navigator not launching.

Jupyter notebook does not launch (ImportError: DLL load failed while importing)

Recently my jupyter notebook stopped launching. When I try the command jupyter notebook from anaconda prompt but it gives error
Traceback (most recent call last):
File "C:\Users\Dell\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\Dell\anaconda3\lib\site-packages\notebook\notebookapp.py", line 51, in
from zmq.eventloop import ioloop
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq_init_.py", line 50, in
from zmq import backend
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq\backend_init_.py", line 40, in
reraise(*exc_info)
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq\backend_init_.py", line 27, in
ns = select_backend(first)
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = import(name, fromlist=public_api)
File "C:\Users\Dell\anaconda3\lib\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.
I even tried reinstalling anaconda and upgraded to python 3.8.3 on windows 10 but still get the same error. When I tried to check jupyter notebook's version it said that ipykernel and some other things were not installed. jupyter --version gives me this:
jupyter core : 4.6.3
jupyter-notebook : 6.1.1
qtconsole : 4.7.6
ipython : 7.18.1
ipykernel : not installed
jupyter client : not installed
jupyter lab : not installed
nbconvert : 5.6.1
But installing ipykernel with conda install ipykernel says
All requested packages already installed.
I also tried ipython kernel install --name <env_name> --user but this gives another dll error.
Reading some other problems in stackoverflow I went and checked my enviroment variables.
Is there a problem with this environment variable. Please help.
Screenshot of the anaconda prompt with error.
Edit: The anaconda navigator does not launch either. anaconda-navigator on the anaconda prompt gives another error:
I also tried:
conda install qt --force
conda install pyqt --force
But that did'nt help. Does previously installed anaconda cause such error?
Just for other people having similar issue.
In my case, when I run jupyter notebook on command line, I got the same error as #Anav Katwal . However if I run jupyter notebook on Anaconda Prompt, then the error is gone.
If you truly want to execute jupyter notebook on cmd, then you could add the following paths to your system environment variable:
C:\Users\USERNAME\anaconda3\Library\bin
C:\Users\USERNAME\anaconda3\Scripts
C:\Users\USERNAME\anaconda3\condabin
What worked for me was reinstalling one of the modules jupyter calls and reinstalling the newer version manually, via another SO answer:
pip uninstall pyzmq
pip install pyzmq==20
Import error while trying to run jupyter notebook
I found what I did wrong (silly me). Microsoft visual C++ 2015-2019 was somehow removed when I tried to install openCV manually. Didn't think that such an install would make such big impact, have to keep that in mind now but installing the latest solved all the problems.
P.S.: This solution might not work for someone else with similar problem. But its worth taking a note.
Use this code, instead of conda
pip install jupyter

Spyder is not launching from Anaconda Navigator, on Windows

While launching Spyder from Anaconda Navigator or directly from the menu, it is showing the given error message:
Traceback (most recent call last):
File "C:\Users\charchil\anaconda3\Scripts\spyder-script.py", line 6, in
from spyder.app.start import main
File "C:\Users\charchil\anaconda3\lib\site-packages\spyder\app\start.py", line 22, in
import zmq
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq_init_.py", line 47, in
from zmq import backend
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\backend_init_.py", line 40, in
reraise(*exc_info)
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\utils\sixcerpt.py", line 34, in
reraise raise value
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\backend_init_.py", line 27, in
ns = select_backend(first)
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\backend\select.py", line 28, in
select_backend mod = import(name, fromlist=public_api)
File "C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from 'zmq.backend.cython' (C:\Users\charchil\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython_init_.py)
A similar issue was raised on Jupyter Notebooks GitHub so it seems likely that a similar solution will help you, i.e.:
Attempt:
conda uninstall pyzmq
conda install pyzmq
Using the conda packages should make sure that version compatibility is maintained. If, however, that still doesn't work (and some comments in the attached issue suggested that it didn't work for some people), attempt:
pip uninstall pyzmq
pip install pyzmq
You can check your version of pip with pip --version and might want to consider upgrading it first if it is a long way behind. Current version is 20.1.1. Command to upgrade pip is:
python -m pip install --upgrade pip
Open the Anaconda prompt
conda deactivate
conda update anaconda-navigator
https://docs.anaconda.com/anaconda/navigator/update-navigator/
For those who are still looking for a quicker answer then below solution might help you as well and this worked for me like a charm.
Open Anaconda Prompt
Run the command conda update --all
Re launch the Anaconda Navigator now
Now Launch, spyder or jupyter notebook. Probably it should work for you as well.
NOTE: If you are running any firewall application then, make sure you launch navigator in administrator mode and unblock any prompt requests accordingly for smooth launching. This is on windows systems again and may be a different way for other platforms.
Hope this helps someone in need again. All the best.

How to install packages in Anaconda environment in VScode?

I am running my code in VScode, my python interpreter being Anconda3\python.exe . When running the following code : -
from Ipython import display
I encounter the following error in the python terminal :
PS C:\Users\Clover\Desktop\Speech Recognition> C:/ProgramData/Anaconda3/python.exe "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py"
Traceback (most recent call last):
File "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py", line 11, in <module>
from Ipython import display
ModuleNotFoundError: No module named 'Ipython'
I've tried to install it on the conda terminal using :
pip install ipython
and it shows that requirement already satisfied which means the package is installed but why is this package not detected in VScode?
At least there is the warning from the conda developers: Never mix conda-forge installs and pip installs. This might help.

Can't use Jupyter Notebook: jsonschema apparently missing

When using an Anaconda environment, I can't start Jupyter to work in a notebook. I can do so without the environment, but I need to be able to use the environment. Here's what I do and the errors I get:
ben#ben-K60IJ:~/surveillance_sound_classifier/surveillance_sound_classifier$ source activate EECS352
discarding /home/ben/anaconda/bin from PATH
prepending /home/ben/anaconda/envs/EECS352/bin to PATH
(EECS352)ben#ben-K60IJ:~/surveillance_sound_classifier/surveillance_sound_classifier$ jupyter notebook
Traceback (most recent call last):
File "/home/ben/anaconda/envs/EECS352/bin/jupyter-notebook", line 4, in <module>
import notebook.notebookapp
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/notebook/notebookapp.py", line 61, in <module>
from .services.contents.manager import ContentsManager
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 16, in <module>
from nbformat import sign, validate, ValidationError
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/nbformat/validator.py", line 21, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: No module named functools32
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
Yes, I've done pip install jsonschema and conda install jsonschema AND pip install functools32 and conda install functools32 from within the EECS352 environment to no avail; I arrive at an almost identical error, except this time, functools32 is replaced with _version.
I've reinstalled Anaconda, updated all its packages, created a new environment in the same way I created this one, and still I get this error. I'm using Ubuntu 15.10 32-bit. I used to be able to use this environment with no problems until roughly a week ago.
If this is a duplicate, please point me to the original; however, I haven't yet found anything that seems really relevant. The only thing that might be relevant is that this error did pop up after I modified some .conf file because I was having issues updating my computer's software using sudo apt-get upgrade. I don't recall what I had done and to which file, but if it's likely the source of this issue, I can spend some time trying to track it down. Please let me know if I should spend my time to do this, and I will.
I think I have a solution.
I did may things, regenerated my env (anaconda env) from another computer where it worked, but no success.
What I think that nailed it is upgrading jsonschema to 2.5.1
Here are my steps from "bad" jupyter env to working jupyter env.
Good luck and come back if it doesn't work, I will post the notebook* relevant versions.
>conda upgrade pip
pip: 8.1.0-py27_0 --> 8.1.1-py27_0
setuptools: 20.2.2-py27_0 --> 20.3-py27_0
>pip install functools32
Downloading functools32-3.2.3-2.tar.gz
Successfully installed functools32-3.2.3.post2
>jupyter notebook
ImportError: No module named _version
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
>pip install jsonschema
Requirement already satisfied
>pip install --upgrade jsonschema
Collecting jsonschema
Downloading jsonschema-2.5.1-py2.py3-none-any.whl
Successfully uninstalled jsonschema-2.4.0
Successfully installed jsonschema-2.5.1
>jupyter notebook
[I 16:45:41.708 NotebookApp] Writing notebook server cookie secret to
[I 16:45:42.134 NotebookApp] Serving notebooks from local directory:
[I 16:45:42.134 NotebookApp] 0 active kernels
[I 16:45:42.134 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
i also got the same error and none of the above mentioned procedures worked for me so i've checked the documentation of anaconda and found something useful
conda install -c conda-forge/label/cf201901 jsonschema
conda install jupyter
jupyter notebook
this worked for me,thanks to anaconda documentation
Re-install jsonschema solve the problem in my case:
$ pip uninstall jsonschema
...
$ pip install jsonschema
...
If any of the above mentioned solution didn't work then try this in your anaconda prompt: First run conda update -n root conda so you have the latest conda version installed. Then run conda update --all This will update all packages in the current environment to the latest version.
Even after installing jsonschema, your Jupyter Notebook might not run and give you the error:
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first
Then I suggest you to run the given two commands. It will solve your issue as it solved mine.
Try this from the terminal:
pip install ipython[notebook]
It worked for me, let me know if the problem still exists.
I had the same problem.
I solved it by running this command
conda install -c anaconda jsonschema
https://anaconda.org/anaconda/jsonschema
I solved it by just uninstalling and reinstalling python 3.7
Try this from terminal, it worked to me:
pip install --upgrade pyrsistent

Categories