Kernel error win32api
lueenavarro opened this issue ยท 27 comments
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.
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! ๐
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
Why is this bug closed? According to this:
mhammond/pywin32#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.
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).
This issue is still valid for the latest version of Anaconda.
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.
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 your PATH
variable.
On Windows, you can locate executables found in PATH
directories using the following command:
where.exe python.exe
Please note that if you run it from PowerShell, you have to explicitly type where.exe
, as where
will resolve to Where-Object
, a different utility.
You will get a list of all absolute paths to python.exe
, select the first one, like:
C:\tools\miniconda3\envs\my_env\python.exe
cd
to the folder containing python.exe
by e.g. copy-pasting part of the path you got from running the previous command.
From there you can run python.exe Scripts/pywin32_postinstall.py -install
as-is.
Faced the same issue and fixed it now.
Please follow these steps:
- Install
pywin32
usingconda install pywin32
, and - Uninstall
pywin32
usingpip uninstall pywin32
I think the issue is, pip pywin32
was conflicting with conda
Interesting possible workaround but not a fix.
I just did pip install pywin32
Then did jupyter notebook again, and it worked
Faced the same issue and fixed it now.
Please follow these steps:
- Install
pywin32
usingconda install pywin32
, and- Uninstall
pywin32
usingpip uninstall pywin32
I think the issue is,
pip pywin32
was conflicting withconda
It works for me.
No it does not work even after installing the pywin32
when you install conda and then download vscode the kernal dir have been changed in vscode jupyter from anaconda jupyter that why it shows win32api error
you just have to change kernal dir back to conda jupyter notebook
FWIW, jupyter/jupyter_core#230 replaces pywin32 with ctypes. No more win32api import errors and works on Python 3.10 and PyPy...
python [environment path]/Scripts/pywin32_postinstall.py -install
Working Awesome
How can this still be an issue in 2022...? Can't believe annoying bugs like these aren't fixed.
Luckily after banging my head on the wall for a good while by trying all the tens of different proposed solutions, I did the same as @ValentinVerschinin and it worked.
Just annoying that so many people have to deal with this issue even though it has been known for so long.
How can this still be an issue in 2022...?
Because the installation of pywin32 using wheels is fundamentally broken and requires manual pre- and/or post-install steps.
Can't believe annoying bugs like these aren't fixed.
The original issue was fixed in jupyter_core 4.8.
Please provide the package versions and a full traceback. There might be packages other than jupyter_core that depend on pywin32 and fail to import if the pywin32 installation is incomplete or corrupted.