Kernel error in jupyter notebook
km.start_kernel(**kwargs)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Khushboo.Girotra\anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.```
I have re-install the anaconda as well . but still It is showing the same kernel error.
Kernel json file shows :
{
"argv": [
"C:\\Users\\Khushboo.Girotra\\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
I have tried lot of solution which are already there but nothing works out . Kindly help
Kindly respond
You might want to be sure the latest version (5.3.3) of jupyter_client is fully installed. Looks like this portion of its setup.py didn't run pywin32 >=1.0 ; sys_platform == 'win32'.
It's 5.3.3 version only but there is no file = setup.py under jupyter _client. Kindle elaborate
jupyter core : 4.5.0 jupyter-notebook : 6.0.1 qtconsole : 4.5.5 ipython : 7.8.0 ipykernel : 5.1.2 jupyter client : 5.3.3 jupyter lab : 1.1.3 nbconvert : 5.6.0 ipywidgets : 7.5.1 nbformat : 4.4.0 traitlets : 4.3.2
I'm referring to the setup.py that's in the repository: https://github.com/jupyter/jupyter_client/blob/5.3.3/setup.py
This file isn't laid down during installation but it's what is used during jupyter_client's installation.
You might try pip install --upgrade jupyter_client. You should have pywin32 installed.
I have installed anaconda , under that jupyter notebook also get installed . I have 5.3.3 version and pywin32 is installed . Still there is kernel error.
I have 5.3.3 version and pywin32 is installed . Still there is kernel error.
Is the kernel failure still due to a DLL load failure - or something different now?
ImportError: DLL load failed: The specified procedure could not be found.
It's a same error of DLL load failed
file:///C:/Users/Khushboo.Girotra/AppData/Roaming/jupyter/runtime/nbserver-13148-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ecaf07a435edebf1a26c758893d1dac7c4996693520529ff
or http://127.0.0.1:8888/?token=ecaf07a435edebf1a26c758893d1dac7c4996693520529ff
[W 22:08:54.472 NotebookApp] Notebook Documents/Analytics bootcamp/python_decision_trees/decision_trees/decision_trees.ipynb is not trusted
[E 22:08:58.108 NotebookApp] Uncaught exception POST /api/sessions (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Khushboo.Girotra\anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
[W 22:08:58.140 NotebookApp] Unhandled error
[E 22:08:58.140 NotebookApp] {
"Content-Type": "application/json",
"Accept": "application/json, text/javascript, */*; q=0.01",
"X-Xsrftoken": "2|272e5111|35d3dd9abc94bc322626eb0226eb4688|1568606969",
"X-Requested-With": "XMLHttpRequest",
"Referer": "http://localhost:8888/notebooks/Documents/Analytics%20bootcamp/python_decision_trees/decision_trees/decision_trees.ipynb",
"Accept-Language": "en-IN",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
"Host": "localhost:8888",
"Content-Length": "163",
"Connection": "Keep-Alive",
"Cache-Control": "no-cache",
"Cookie": "_xsrf=2|272e5111|35d3dd9abc94bc322626eb0226eb4688|1568606969; username-localhost-8890=\"2|1:0|10:1569241500|23:username-localhost-8890|44:NjhmYTcwN2UyOWU3NGZkN2EzNDg2NWNkYWRiYjAwM2M=|2dd0b3cbedd7aec9ddb5a5487f6431906a442b75380dd0587e1d1b3e9f5f7475\"; username-localhost-8889=\"2|1:0|10:1569253558|23:username-localhost-8889|44:Mjg4OTcwZjIyMzJiNDkzMDkwZmVhZGY1Mzk2MGIwMGQ=|16708bbdcf21858ebb05eb126eea8fd1d1d23a770dd78f4c00427469bfa17d3c\"; username-localhost-8888=\"2|1:0|10:1569256712|23:username-localhost-8888|44:YjZkM2JjZDAwZmEyNDllMWI0NThhNzg0OTQ1YTRjM2M=|4d33dac2a071434c20d5ed0e0320c827950ec822c40925d68aa42b936e1e39e7\""
}
[E 22:08:58.155 NotebookApp] 500 POST /api/sessions (::1) 312.31ms referer=http://localhost:8888/notebooks/Documents/Analytics%20bootcamp/python_decision_trees/decision_trees/decision_trees.ipynb```
Thanks for the update. You'll need to figure out why import win32api is not working. There are a number of SO hits on this issue, some of which state that pip install pypiwin32 resolved the issue. I don't have access to a windows machine, so can't really help much more than this - sorry.
Thanks for giving me the directions !
Now it shows me the error of dead kernel. Kindly help on this
[I 10:33:32.182 NotebookApp] Loading IPython parallel extension
[I 10:33:32.292 NotebookApp] JupyterLab extension loaded from C:\Users\Khushboo.Girotra\anaconda3\lib\site-packages\jupyterlab
[I 10:33:32.292 NotebookApp] JupyterLab application directory is C:\Users\Khushboo.Girotra\anaconda3\share\jupyter\lab
[I 10:33:32.297 NotebookApp] Serving notebooks from local directory: C:\Users\Khushboo.Girotra
[I 10:33:32.298 NotebookApp] The Jupyter Notebook is running at:
[I 10:33:32.299 NotebookApp] http://localhost:8888/?token=8e24cc355a607b399fedca623643ddf1b2ebb428f69c39bc
[I 10:33:32.300 NotebookApp] or http://127.0.0.1:8888/?token=8e24cc355a607b399fedca623643ddf1b2ebb428f69c39bc
[I 10:33:32.301 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:33:32.755 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/Khushboo.Girotra/AppData/Roaming/jupyter/runtime/nbserver-8844-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=8e24cc355a607b399fedca623643ddf1b2ebb428f69c39bc
or http://127.0.0.1:8888/?token=8e24cc355a607b399fedca623643ddf1b2ebb428f69c39bc
[W 10:33:50.064 NotebookApp] Notebook Documents/Analytics bootcamp/python_decision_trees/decision_trees/decision_trees.ipynb is not trusted
[I 10:33:53.885 NotebookApp] Kernel started: a869e91b-d19d-478e-b2a7-6fda11ce89f5
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Khushboo.Girotra\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\traitlets\config\application.py", line 657, in launch_instance
app.initialize(argv)
File "<C:\Users\Khushboo.Girotra\lib\site-packages\decorator.py:decorator-gen-125>", line 2, in initialize
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 530, in initialize
self.write_connection_file()
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 227, in write_connection_file
iopub_port=self.iopub_port, control_port=self.control_port)
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Khushboo.Girotra\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
[I 10:33:59.591 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\Khushboo.Girotra\\AppData\\Roaming\\jupyter\\runtime\\kernel-a869e91b-d19d-478e-b2a7-6fda11ce89f5.json'
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 252, in init_connection_file
self.load_connection_file()
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 569, in load_connection_file
info = json.load(f)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 10:34:02.637 NotebookApp] KernelRestarter: restarting kernel (2/5), keep random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\Khushboo.Girotra\\AppData\\Roaming\\jupyter\\runtime\\kernel-a869e91b-d19d-478e-b2a7-6fda11ce89f5.json'
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 252, in init_connection_file
self.load_connection_file()
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 569, in load_connection_file
info = json.load(f)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 10:34:05.668 NotebookApp] KernelRestarter: restarting kernel (3/5), keep random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\Khushboo.Girotra\\AppData\\Roaming\\jupyter\\runtime\\kernel-a869e91b-d19d-478e-b2a7-6fda11ce89f5.json'
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 252, in init_connection_file
self.load_connection_file()
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 569, in load_connection_file
info = json.load(f)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 10:34:08.695 NotebookApp] KernelRestarter: restarting kernel (4/5), keep random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\Khushboo.Girotra\\AppData\\Roaming\\jupyter\\runtime\\kernel-a869e91b-d19d-478e-b2a7-6fda11ce89f5.json'
Traceback (most recent call last):
File "C:\Users\Khushboo.Girotra\AppData\Roaming\Python\Python37\site-packages\ipykernel\kernelapp.py", line 252, in init_connection_file
self.load_connection_file()
File "C:\Users\Khushboo.Girotra\lib\site-packages\jupyter_client\connect.py", line 569, in load_connection_file
info = json.load(f)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\Khushboo.Girotra\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Khushboo.Girotra\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[W 10:34:11.713 NotebookApp] KernelRestarter: restart failed
[W 10:34:11.714 NotebookApp] Kernel a869e91b-d19d-478e-b2a7-6fda11ce89f5 died, removing from map.
[W 10:34:54.178 NotebookApp] Timeout waiting for kernel_info reply from a869e91b-d19d-478e-b2a7-6fda11ce89f5
[E 10:34:54.181 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: a869e91b-d19d-478e-b2a7-6fda11ce89f5)
[W 10:34:55.240 NotebookApp] 404 GET /api/kernels/a869e91b-d19d-478e-b2a7-6fda11ce89f5/channels?session_id=fe921aa3776f48e79b7232347f66318f (::1): Kernel does not exist: a869e91b-d19d-478e-b2a7-6fda11ce89f5
[W 10:34:55.286 NotebookApp] 404 GET /api/kernels/a869e91b-d19d-478e-b2a7-6fda11ce89f5/channels?session_id=fe921aa3776f48e79b7232347f66318f (::1) 46.89ms referer=None
[W 10:34:57.395 NotebookApp] Replacing stale connection: a869e91b-d19d-478e-b2a7-6fda11ce89f5:fe921aa3776f48e79b7232347f66318f```
This is still the same issue, failed import of win32api. Did you try pip install pywin32 into the correct environment? Looks like you're hitting this issue: https://github.com/conda-forge/jupyter_client-feedstock/issues/29 (so at least you're not alone :smile:)
I have installed pywin32 , what does correct environment mean here?
How should I resolve it ? I tried a lot reading lot of stuffs on github and solving it, but nothing works out. Please help
If you're dealing with virtual envs or conda environments, where you installed pywin32 matters. I would create a one line python script that imports win32api and get that python script to not throw ModuleNotFoundError.
import win32api
save into import_win32api.py. If you invoke python import_win32api.py in the same env as you run Notebook, you should get something like ModuleNotFoundError: No module named 'win32api'. You'll know things are better when that same invocation yields nothing (indicating the import statement worked).
Also focus on where your python command is coming from (and relative to your jupyter command). The multiple envs can be confusing.
((I had also referenced pypiwin32 before since that's what SO posts used, but try pywin32 as well.))
I got this error when I run this :
(base) C:\Users\Khushboo.Girotra>python import_win32api.py
Traceback (most recent call last):
File "import_win32api.py", line 1, in
That's good actually. So now try to get pywin32 installed in such a way that the import statement succeeds.
but how ? what's the other way
Try conda install pywin32 if you are using conda.