Notebook: Kernel error win32api

Created on 17 Oct 2019  路  14Comments  路  Source: jupyter/notebook

After launching any notebook, I get the following error.

Traceback (most recent call last):
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\lnavarro6\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\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\lnavarro6\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\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\Users\lnavarro6\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\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
    self.write_connection_file()
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 476, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
    with secure_write(fname) as f:
  File "C:\Users\lnavarro6\AppData\Local\Continuum\anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 404, in secure_write
    win32_restrict_file_to_user(fname)
  File "C:\Users\lnavarro6\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed: The specified procedure could not be found.

Most helpful comment

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python [environment path]/Scripts/pywin32_postinstall.py -install

After hours this worked for me!

All 14 comments

Rumors abound there's an installation glitch in the 225 build of pywin32. Have you tried conda install pywin32?

Don't know how you installed pywin32, but you may be missing the system files.

Try downloading a precompiled wheel from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32

And install pywin32 system files, cd into your PYTHONPATH, and run python.exe Scripts/pywin32_postinstall.py -install from an elevated command prompt.

Had the same issue and pip uninstall pywin32 and installing it again helped. conda install pywin32 didn't work, however.

Can confirm @ValentinVerschinin solution worked. Thanks for trouble shooting this several hours before me!

Thanks @ValentinVerschinin it worked!.

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python [environment path]/Scripts/pywin32_postinstall.py -install

After hours this worked for me!

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python [environment path]/Scripts/pywin32_postinstall.py -install

After hours this worked for me!

陌t worked too

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python [environment path]/Scripts/pywin32_postinstall.py -install

After hours this worked for me!

It also worked for me. Cheers bro!

Too many successes - time to close! :smile:

The easiest thing for me was to pip uninstall it and then conda install it.

Re.: python [environment path]/Scripts/pywin32_postinstall.py -install

How do I find out what I have to type where it states [environment path]?
Do I have to type this in the CMD prompt: "(base) C:\Users\User" ?

Yes, you need to run it in command prompt and after activating the environment where you did install pywin32. If you are using miniconda and you installed it in base environment it will be:

C:\Users\<USERNAME>\miniconda3\Scripts

if you used another environment first activate it and then try to locate the script in:

C:\Users\<USERNAME>\miniconda3\envs\<ENV_NAME>\Scripts

If you are using virtualenv then try to find the script in that environment's folder.

When I go to
"(base) C:\Users\User>"
I type in "cd miniconda" but I am getting this error message:
"The system cannot find the path specified."
What happened there?

conda install pywin32 worked for me. I am using Python 3.8

Was this page helpful?
0 / 5 - 0 ratings