首页 > 解决方案 > 如何修复 Jupyter 内核错误 - 内核已死

问题描述

由于我重新安装了 windows,所以我遇到了 jupyter 的问题,内核已经死了,我尝试使用 pip、anaconda 和 vs 代码安装和重新安装,但总是死了,非常令人沮丧。

我确定我遗漏了一些东西,因为在我重新安装 Windows 之前它运行良好。

这是我使用 anaconda 从 jupyter 获得的报告

> [W 2021-07-19 10:24:55.987 LabApp] 'notebook_dir' has moved from
> NotebookApp to ServerApp. This config will be passed to ServerApp. Be
> sure to update your config before our next release. [W 2021-07-19
> 10:24:55.987 LabApp] 'notebook_dir' has moved from NotebookApp to
> ServerApp. This config will be passed to ServerApp. Be sure to update
> your config before our next release. [I 2021-07-19 10:24:55.999
> LabApp] JupyterLab extension loaded from
> C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab [I 2021-07-19
> 10:24:55.999 LabApp] JupyterLab application directory is
> C:\ProgramData\Anaconda3\share\jupyter\lab [I 10:24:55.999
> NotebookApp] Serving notebooks from local directory: C:\Users\Carlos
> [I 10:24:55.999 NotebookApp] Jupyter Notebook 6.3.0 is running at: [I
> 10:24:55.999 NotebookApp]
> http://localhost:8888/?token=75a17c7be9d6b9a56b36c63e9df28370ec47027a73037047
> [I 10:24:55.999 NotebookApp]  or
> http://127.0.0.1:8888/?token=75a17c7be9d6b9a56b36c63e9df28370ec47027a73037047 [I 10:24:55.999 NotebookApp] Use Control-C to stop this server and
> shut down all kernels (twice to skip confirmation). [C 10:24:56.055
> NotebookApp]
> 
>     To access the notebook, open this file in a browser:
>         file:///C:/Users/Carlos/AppData/Roaming/jupyter/runtime/nbserver-6048-open.html
>     Or copy and paste one of these URLs:
>         http://localhost:8888/?token=75a17c7be9d6b9a56b36c63e9df28370ec47027a73037047
>      or http://127.0.0.1:8888/?token=75a17c7be9d6b9a56b36c63e9df28370ec47027a73037047 [W 10:25:01.732 NotebookApp] Notebook Untitled.ipynb is not trusted [E
> 10:25:01.810 NotebookApp] Uncaught exception POST /api/sessions
> (127.0.0.1)
>     HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1',
> remote_ip='127.0.0.1')
>     Traceback (most recent call last):
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\web.py",
> line 1704, in _execute
>         result = await result
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 769, in run
>         yielded = self.gen.throw(*exc_info)  # type: ignore
>       File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py",
> line 69, in post
>         model = yield maybe_future(
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 762, in run
>         value = future.result()
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 769, in run
>         yielded = self.gen.throw(*exc_info)  # type: ignore
>       File "C:\ProgramData\Anaconda3\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:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 762, in run
>         value = future.result()
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 769, in run
>         yielded = self.gen.throw(*exc_info)  # type: ignore
>       File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py",
> line 110, in start_kernel_for_session
>         kernel_id = yield maybe_future(
>       File "C:\Users\Carlos\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py",
> line 762, in run
>         value = future.result()
>       File "C:\ProgramData\Anaconda3\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:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py",
> line 186, in start_kernel
>         km.start_kernel(**kwargs)
>       File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py",
> line 337, in start_kernel
>         kernel_cmd, kw = self.pre_start_kernel(**kw)
>       File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py",
> line 286, in pre_start_kernel
>         self.write_connection_file()
>       File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py",
> line 466, in write_connection_file
>         self.connection_file, cfg = write_connection_file(self.connection_file,
>       File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py",
> line 136, 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:\ProgramData\Anaconda3\lib\site-packages\jupyter_core\paths.py",
> line 461, in secure_write
>         win32_restrict_file_to_user(fname)
>       File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_core\paths.py",
> line 387, in win32_restrict_file_to_user
>         import win32api
>     ImportError: DLL load failed while importing win32api: The specified procedure could not be found. [W 10:25:01.810 NotebookApp]
> Unhandled error [E 10:25:01.826 NotebookApp] {
>       "Host": "localhost:8888",
>       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0",
>       "Accept": "application/json, text/javascript, */*; q=0.01",
>       "Accept-Language": "en-US,en;q=0.5",
>       "Accept-Encoding": "gzip, deflate",
>       "Content-Type": "application/json",
>       "X-Xsrftoken": "2|42a9aa87|22d5ae0bdb2d45cbfbe6fb94fdde3a40|1626659361",
>       "X-Requested-With": "XMLHttpRequest",
>       "Content-Length": "91",
>       "Origin": "http://localhost:8888",
>       "Connection": "keep-alive",
>       "Referer": "http://localhost:8888/notebooks/Untitled.ipynb",
>       "Cookie": "username-localhost-8888=\"2|1:0|10:1626661497|23:username-localhost-8888|44:N2U1OTVkZGQ1Y2ZiNGNjZjhiZDI4ZTMzMzY0NDY5NjM=|684c8e904cd24bbe4b7ff0cdd33e7fb62f992597759b83f8d79bc07ca31d986b\";
> _xsrf=2|42a9aa87|22d5ae0bdb2d45cbfbe6fb94fdde3a40|1626659361",
>       "Sec-Fetch-Dest": "empty",
>       "Sec-Fetch-Mode": "cors",
>       "Sec-Fetch-Site": "same-origin"
>     } [E 10:25:01.826 NotebookApp] 500 POST /api/sessions (127.0.0.1) 46.880000ms referer=http://localhost:8888/notebooks/Untitled.ipynb

标签: jupyter

解决方案


推荐阅读