python 3.8+vscode 无法启动jupyter kernal问题

在python 3.8环境下,所有包更新到最新之后,使用vscode打开ipynb,提示`kerkal died with exit code 1.` 通过命令行启动jupyter notebook,提示启动内核失败,现象如下:

python 3.8+vscode 无法启动jupyter kernal问题_第1张图片

详细报错信息是:

```

Traceback (most recent call last):
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\web.py", line 1704, in _execute
    result = await result
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 769, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\work\projects\test_robot\venv\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
    model = yield maybe_future(
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 762, in run
    value = future.result()
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 769, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\work\projects\test_robot\venv\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 98, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 762, in run
    value = future.result()
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 769, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\work\projects\test_robot\venv\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
    kernel_id = yield maybe_future(
  File "c:\work\projects\test_robot\venv\lib\site-packages\tornado\gen.py", line 762, in run
    value = future.result()
  File "c:\work\projects\test_robot\venv\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 176, in start_kernel
    kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\utils.py", line 25, in wrapped
    return loop.run_until_complete(coro(*args, **kwargs))
  File "c:\work\projects\test_robot\venv\lib\site-packages\nest_asyncio.py", line 70, in run_until_complete
    return f.result()
  File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 178, in result
    raise self._exception
  File "C:\ProgramData\Anaconda3\lib\asyncio\tasks.py", line 280, in __step
    result = coro.send(None)
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\multikernelmanager.py", line 214, in _async_start_kernel
    self._add_kernel_when_ready(kernel_id, km, ensure_async(km.start_kernel(**kwargs)))
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\utils.py", line 25, in wrapped
    return loop.run_until_complete(coro(*args, **kwargs))
  File "c:\work\projects\test_robot\venv\lib\site-packages\nest_asyncio.py", line 70, in run_until_complete
    return f.result()
  File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 178, in result
    raise self._exception
  File "C:\ProgramData\Anaconda3\lib\asyncio\tasks.py", line 280, in __step
    result = coro.send(None)
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\manager.py", line 372, in _async_start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\manager.py", line 316, in pre_start_kernel
    self.write_connection_file()
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\connect.py", line 510, in write_connection_file
    self.connection_file, cfg = write_connection_file(
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_client\connect.py", line 158, in write_connection_file
    with secure_write(fname) as f:
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
    win32_restrict_file_to_user(fname)
  File "c:\work\projects\test_robot\venv\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: 找不到指定的程序。

```

参考 https://blog.csdn.net/Zhou_August/article/details/109121347

把pywin32版本降级到228,就解决了。

1
 

你可能感兴趣的:(python)