简体   繁体   中英

Jupyter failed to start kernel

So I just installed anaconda 3 and ran "jupyter notebook" in the anaconda prompt, which opened 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

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. 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.

{
 "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:

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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