简体   繁体   English

Jupyter 无法启动内核

[英]Jupyter failed to start kernel

So I just installed anaconda 3 and ran "jupyter notebook" in the anaconda prompt, which opened jupyter.所以我刚刚安装了 anaconda 3 并在 anaconda 提示符下运行了“jupyter notebook”,它打开了 jupyter。 However, when I opened a new python 3 notebook, I couldn't run any code because of kernel error "failed to start the kernel" with the following error message但是,当我打开一个新的 python 3 notebook 时,我无法运行任何代码,因为内核错误“无法启动内核”并显示以下错误消息

Traceback (most recent call last):
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Janko\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Janko\Anaconda3\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\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Janko\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Janko\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\Users\Janko\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\Users\Janko\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\Janko\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
    self.write_connection_file()
  File "C:\Users\Janko\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\Users\Janko\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
    with secure_write(fname) as f:
  File "C:\Users\Janko\Anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\Users\Janko\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 102, in secure_write
    with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Janko\\AppData\\Roaming\\jupyter\\runtime\\kernel-624a372e-0a69-4eda-8068-85cfa1e7c4bd.json'

I tried googling around but couldn't find a fix.我尝试谷歌搜索,但找不到解决办法。 Keep in mind I'm not terribly well acquainted with kernels, environments and other lingo I've read in replies to similar issues, so my troubleshooting capabilities are rather limited (sorry).请记住,我对内核、环境和我在对类似问题的回复中读到的其他行话并不十分熟悉,因此我的故障排除能力相当有限(抱歉)。 Here's my kernels.json file (which does contain the correct path to the python executable) to which responses to similar issues are often tied to.这是我的 kernels.json 文件(其中包含 python 可执行文件的正确路径),对类似问题的响应通常与之相关。 Another thing I'm confused by is the file path having double backslashes, but if I changed to single, jupyter would say kernel not found.我感到困惑的另一件事是文件路径具有双反斜杠,但如果我改为单反,jupyter 会说未找到内核。

{
 "argv": [
  "C:\\Users\\Janko\\Anaconda3\\python.exe",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

Thanks!谢谢!

The last line of the stack trace tells you in which directory Jupyter couldn't write:堆栈跟踪的最后一行告诉您 Jupyter 无法写入的目录:

Permission denied: 'C:\\Users\\Janko\\AppData\\Roaming\\jupyter\\runtime\\kernel-624a372e-0a69-4eda-8068-85cfa1e7c4bd.json'

Either grant permissions for writing into that directory to the user who's running Jupyter, or set the environment variable JUPYTER_RUNTIME_DIR to a writeable directory.向运行 Jupyter 的用户授予写入该目录的权限,或者将环境变量JUPYTER_RUNTIME_DIR设置为可写目录。

https://jupyter.readthedocs.io/en/latest/projects/jupyter-directories.html https://jupyter.readthedocs.io/en/latest/projects/jupyter-directories.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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