简体   繁体   中英

Getting kernel error while trying to open Jupyter notebook or Spyder

While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification.

Tried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.

I am getting the below error in log.

"> Traceback (most recent call last): File "> "C:\Users\AppData\Local\Continuum\anaconda3\lib\site‑packages\spyder\plugins\ipytho"nconsole.py",

line 1572, in create_kernel_manager_and_kernel_client kernel_manager.start_kernel(stderr=stderr_handle) File "C:\Users\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\manager.py", line 240, in start_kernel self.write_connection_file() File "C:\Users\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\connect.py", line 476, in write_connection_file kernel_name=self.kernel_name File "C:\Users\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\AppData\Local\Continuum\anaconda3\lib\contextlib.py", line 112, in enter return next(self.gen) File "C:\Users\AppData\Roaming\Python\Python37\site‑packages\jupyter_core\paths.py", line 404, in secure_write win32_restrict_file_to_user(fname) File "C:\Users\AppData\Roaming\Python\Python37\site‑packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user import win32api ImportError: Z5884E40D596370BE5406F2711AD9E39A Z load failed: The specified procedure could not be found.

Its basically system compatible issues with python/Jupiter.

Please locate the file pywin32_postinstall.py in your python installed path

Example

C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts>

And navigate to the path and run the file/command pywin32_postinstall.py -install

pip install pywin32 -U

Should do the trick

After longer looking here and there I found this question but none of answers helped me, after all I have noticed the correct solution in comments, so I add it here as answer for future readers that might not check the comments at first like me.

Downgrading pywin32 to version 224 is the way:

pip install --upgrade pywin32==224 

Copying the win32api file from the..//site-packages/win32 folder to the..//site-packages//jupyter_core folder finally did the trick for me.

Follow this to resolve the issue when a kernel is dead.

pip install --upgrade pywin32==224 (downgrade the pywin32 from 225 to 224) or pip install --upgrade pywin32==224 --user

If the above still not work and one prompt appears that pythoncom37.dll should not be the path 'C:\Windows\System32' then remove the 'pythoncom37.dll' from 'C:\Windows\System32'.

I started all over:

  • I uninstalled notebook.

  • I uninstalled python 3.7.9.

  • I then reinstalled python 3.8.4 and.

  • reinstalled notebook.

Problem solved!

If you are working in a miniconda on conda environment. You could just install pywin32 using conda instead of pip.

This solved my problem

conda install pywin32

I had this issue for several days. I was using Jupyter notebook. Installation was Anaconda and Python version was 3.8.

I did the following to finally get it fixed:

1.I copied the 2 win32 dlls from C:\Users\YourUser\anaconda3\pkgs\pywin32-227-py38he774522_1\Lib\site-packages\pywin32_system32 <path where anaconda is installed

to c:\windows\system32 per advice in this thread (not sure if this was necessary, as this didn't immediately fix the problem. The next 2 steps are what fixed it for me.

2.per this https://github.com/jupyter/notebook/issues/4980#issuecomment-663885620 (he says pip uninstall pywin32 and conda install it.)

I ran a terminal cmd prompt from anaconda navigator (have to be running as admin) to pip uninstall pywin32

I had to look up how to run pip install and uninstall from anaconda installation. Googled how to use pip with anaconda and the following instructions came up which worked great.

  • Open Anaconda. Select Environments in the left hand pane below home. Just to the right of where you selected and below the "search environments" bar, you should see base(root). Click on it. A triangle pointing right should appear, click on it an select "open terminal" Use the regular pip install command here.

3.ran conda install from anaconda prompt as admin per this website, https://anaconda.org/anaconda/pywin32 :
conda install -c anaconda pywin32

Finally Jupyter Kernel stopped crashing.

Try creating a new environment with python 3.9 or 3.10. This is an environment related issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM