针对jupyter启动内核报错“ImportError: DLL load failed while importing win32api: 找不到指定的程序“的解决办法

针对jupyter启动内核报错"ImportError: DLL load failed while importing win32api: 找不到指定的程序"的解决办法

[I 11:40:22.127 NotebookApp] Kernel started: bd8cabbb-5ced-4f2b-aa23-4af5c67b7886, name: pytorch7
Traceback (most recent call last):
  File "D:\software_installed\anaconda\envs\pytorch7\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\software_installed\anaconda\envs\pytorch7\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
    app.initialize(argv)
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\traitlets\config\application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\ipykernel\kernelapp.py", line 625, in initialize
    self.write_connection_file()
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\ipykernel\kernelapp.py", line 234, in write_connection_file
    write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport,
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
    with secure_write(fname) as f:
  File "D:\software_installed\anaconda\envs\pytorch7\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
    win32_restrict_file_to_user(fname)
  File "D:\software_installed\anaconda\envs\pytorch7\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: 找不到指定的程序。
[I 11:40:25.140 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports

在python3.8.10的环境下,使用以下命令将pywin32版本回退到225即可解决,必须将需要启动的内核中的版本回退后才能解决。

pip install --upgrade pywin32==225

你可能感兴趣的:(奇怪的bug,python,jupyter)