notebook: Kernel error win32api
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 27 (5 by maintainers)
Rumors abound there’s an installation glitch in the 225 build of
pywin32
. Have you triedconda install pywin32
?According to pywin32 github you must run
and after that, you must run
After hours this worked for me!
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!
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 yourPYTHONPATH
, and runpython.exe Scripts/pywin32_postinstall.py -install
from an elevated command prompt.İt worked too
Too many successes - time to close! 😄
Thanks @johann-petrak - your point is valid. Rather than re-open this issue, I would suggest a new issue be opened in jupyter_core which is responsible for the
pywin32
requirement within the ecosystem.Please reference your previous comment as to what the issue is. I suspect this will require some conda expertise if I’m understanding the recommendation.
Also, note that Terminal functionality is currently not working in Windows with Python 3.9+ (#5967).
Why is this bug closed? According to this: https://github.com/mhammond/pywin32/issues/1507 the problem arises because of the way how Jupyter bundles the library.
I just got this problem after installing jupyter into a brand now Miniconda installagion, creating a Python 3.9 environment for my packages (On Windows 10)
I think it is unacceptable for Windows users to run into the problem of the kernel not working in Jupyter, googling the problem, finding a closed issue, figuring out some installation/environment path on their computer, and then needing to type in a cryptic command in order to make things work for them.
This should get fixed properly.
conda install pywin32
worked for me. I am using Python 3.8It also worked for me. Cheers bro!
Faced the same issue and fixed it now.
Please follow these steps:
pywin32
usingconda install pywin32
, andpywin32
usingpip uninstall pywin32
I think the issue is,
pip pywin32
was conflicting withconda
Just want to confirm that this solution did work for my conda environment.
For those unable to find Scripts folder or have no PYTHONPATH
This will likely require an elevated (administrator) prompt Once you activated your environment, a correct path to
python.exe
is prepended to yourPATH
variable. On Windows, you can locate executables found inPATH
directories using the following command:where.exe python.exe
Please note that if you run it from PowerShell, you have to explicitly typewhere.exe
, aswhere
will resolve toWhere-Object
, a different utility. You will get a list of all absolute paths topython.exe
, select the first one, like:cd
to the folder containingpython.exe
by e.g. copy-pasting part of the path you got from running the previous command. From there you can runpython.exe Scripts/pywin32_postinstall.py -install
as-is.FWIW, https://github.com/jupyter/jupyter_core/pull/230 replaces pywin32 with ctypes. No more win32api import errors and works on Python 3.10 and PyPy…
This issue is still valid for the latest version of Anaconda.