Shawn
Shawn

Reputation: 163

Jupyter Notebook: Kernel Error on the Right

I have just installed Anaconda and run Jupyter Notebook through command line by using jupyter notebook command. However, I am facing an issue. On the top right, I see Kernel Error. enter image description here When I click on Kernel Error, I see these lines:

Traceback (most recent call last):
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\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\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\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\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 158, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 301, in start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 248, in pre_start_kernel
    self.write_connection_file()
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 474, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
    with secure_write(fname) as f:
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 424, in secure_write
    win32_restrict_file_to_user(fname)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed: %1 is not a valid Win32 application.

I can't run any Python code on Jupyter Notebook, as I am continuing to get that error.

I have gone through numerous threads on Stack Overflow for several hours. But I can't fix the issue. Please, help me to solve the issue. I am doing a course on Data Scince with Python. I can't move forward without fixing this issue.

Update 1: I have visited this Github thread and tried using the following command:

conda install -c conda-forge pywin32
conda install -c anaconda jupyter_client
conda install -c conda-forge jupyter_core
pip install --upgrade pywin32==224

However, the issue is not fixed. Instead, I am getting a new error,

ImportError: DLL load failed: The specified procedure could not be found.

This is really frustrating!

Upvotes: 1

Views: 1732

Answers (3)

12343954
12343954

Reputation: 2621

try this way, i fixed my jupyter.
same error site-packages\tornado

  1. command
    jupyter kernelspec list
  1. from the shown result
     Available kernels:  
      python3    D:\Programs\Anaconda3\share\jupyter\kernels\python3
  1. open the folder, and edit kernel.json
{
    "argv": [
        "D:\\Programs\\Anaconda3\\python.exe",  //change to your correct path
        "-m",
        "ipykernel_launcher",
        "-f",
        "{connection_file}"
    ],
    "display_name": "Python 3",
    "language": "python"
}
  1. restart jupyter, and it will be ok.

Upvotes: 1

Shawn
Shawn

Reputation: 163

Alright. I have managed to fix the issue. I have to write these commands:

conda install -c conda-forge pywin32
conda install -c anaconda jupyter_client
conda install -c conda-forge jupyter_core
pip install --upgrade pywin32==224

Then I got an error.

import win32api pywin32
ImportError: DLL load failed: The specified procedure could not be found.

I solve the issue by writing this command that I got from this github thread:

conda install pywin32

Now, the issue has been completely fixed!

Upvotes: 0

Samruddhi Chitnis
Samruddhi Chitnis

Reputation: 59

Did you try opening the anaconda navigator from terminal and then create an environment their and install the jupyter notebook in that environment and then open the jupyter notebook from the navigator

Upvotes: 0

Related Questions