ImportError: DLL load failed while importing win32api: 找不到指定的模块

我的python环境是3.8,自己手贱更新了pywin32,发现内核出了问题,问题如下:

Error Starting Kernel
Invalid response: 500 Internal Server Error
Unhandled error
详细信息
Traceback (most recent call last):
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\web.py", line 1703, in _execute
    result = await result
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
    model = yield maybe_future(
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\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\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
    kernel_id = yield maybe_future(
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
    km.start_kernel(**kwargs)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_client\manager.py", line 304, in start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_client\manager.py", line 251, in pre_start_kernel
    self.write_connection_file()
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_client\connect.py", line 468, in write_connection_file
    self.connection_file, cfg = write_connection_file(self.connection_file,
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
    with secure_write(fname) as f:
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_core\paths.py", line 435, in secure_write
    win32_restrict_file_to_user(fname)
  File "c:\users\administrator\anaconda3\envs\communitydetection\lib\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: 找不到指定的模块。

首先我百度了kernel的问题,解决方法就是修改kernel.jason,重新添加**kernel*,结果不理想;之后谷歌了的解决方案如下网址:
https://stackoverflow.com/questions/58612306/how-to-fix-importerror-dll-load-failed-while-importing-win32api
解决方案如下:

  • 卸载pywin32(原先版本301):pip uninstall pywin32
  • 安装低版本的pywin32 :pip install pywin32==225
  • 最后检验一下:import win32api 是否能导入成功。
    ImportError: DLL load failed while importing win32api: 找不到指定的模块_第1张图片

你可能感兴趣的:(Python学习,anaconda,内核)