drag88
drag88

Reputation: 80

Why do I have a Kernel Error in Jupyter Notebook?

I am a newbie to python. I am getting the below error in Kernel while opening jupyter notebook. Any ideas how I can resolve it? Installation of jupyter has been done via Anaconda3 - tried reinstalling and setting environment variables, but no luck so far. Any help would be greatly appreciated.

 Traceback (most recent call last):
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
        result = await result
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
        type=mtype))
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\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\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\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\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
        yielded = next(result)
      File "C:\Users\drag88\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\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
        self.write_connection_file()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
        kernel_name=self.kernel_name
      File "C:\Users\drag88\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\drag88\Anaconda3\lib\contextlib.py", line 112, in __enter__
        return next(self.gen)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
        win32_restrict_file_to_user(fname)
      File "C:\Users\drag88\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.

Upvotes: 0

Views: 29591

Answers (7)

jaikumar paswan
jaikumar paswan

Reputation: 1

Simply uninstall and install jupyter by first: #Activate your environment in anaconda prompt (conda activate"path") and then type:-

  1. conda uninstall jupyter
  2. conda install jupyter

Upvotes: 0

tonyb
tonyb

Reputation: 459

I battled to get Jupyter working on my Windows 10 office computer for a number of hours. This was after installing Anaconda3. I had versions of Python 2 and 3 installed before. I was getting 'Kernel error' and also had various errors about 'win32api' and 'tornado'

I did many things but in the end main ones that, I think, helped are listed below -

On install, Anaconda3 created a data folder here -

C:\ProgramData\Anaconda3

I gave my user account access to write to this folder, I am not sure if it made a difference.

Elevated to admin, I copied two dll files as below -

pythoncom39.dll
pywintypes39.dll

From -

C:\ProgramData\Anaconda3\Lib\site-packages\pywin32_system32

To -

C:\windows\system32

At the 'Anaconda Prompt', a Windows cmd screen (which was added to my start menu) after the install, I did this -

(base) C:\>conda env create test-env

It created 'test-env' folder at C:\Users\{windows user name}\.conda\envs\test-env

(base) C:\>conda activate "C:\Users\{windows user name}\.conda\envs\test-env"

(test-env) C:\>

Once in this newly created environment, I tried various other things such as these -

conda install jupyter
conda install pywin32
python -m ipykernal install --user

Launching jupyter after loading and setting to this environment now works by using this command -

(test-env) C:\>jupyter notebook

When browser opens, select New>python 3 (ipykernel) from right hand menu to create new notebook.

Upvotes: 1

Happy Nkanta Monday
Happy Nkanta Monday

Reputation: 429

This error is sometimes as a result of the deleted environment that was created before. For Windows users, run the following code in cmd

python -m ipykernel install –user

Upvotes: 0

Claudio peña
Claudio peña

Reputation: 61

  • Step 2 command: conda activate (location of your env folder)
  • Step 3 command: python -m ipykernel install --user

Works for Windows.

Upvotes: 6

Shivam Batra
Shivam Batra

Reputation: 68

The installation might have missed some steps which are fixed by post_install. Go to yout venv's Script directory and run the command

python .\pywin32_postinstall.py -install

Make sure you are running the shell with Admin rights.

Upvotes: 0

spadequack
spadequack

Reputation: 502

It looks like you had installed jupyter when there was an issue with its dependencies on Windows. See https://github.com/jupyterlab/jupyterlab/issues/7259 . I ran into the same error.

It should be fixed on conda now, so if you uninstall and reinstall jupyterlab from conda, it should not throw that error anymore.

Upvotes: 2

Christophermp
Christophermp

Reputation: 186

If you have Python installed on your pc run from cmd or powershell:

pip install jupyterlab

Then you can start it with:

jupyter lab

Upvotes: 0

Related Questions