Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel error when creating new jupyter notebook #5536

Open
angrosamund opened this issue Jun 16, 2020 · 2 comments
Open

Kernel error when creating new jupyter notebook #5536

angrosamund opened this issue Jun 16, 2020 · 2 comments

Comments

@angrosamund
Copy link

Hi all!

I'm having trouble running the cells in my jupyter notebooks, and there's a 'KERNEL ERROR' stated in a red box at the top of my notebook. May I know how to resolve this? Below are the steps I took and the error message I got from my Ubuntu terminal. Thank you!

Steps I took:

  1. Installed Anaconda 2020.02 on Ubuntu 20.04 LTS for WSL
  2. export BROWSER='jupyter-notebook-browser'
  3. jupyter-notebook
  4. create new jupyter notebook in browser

Error Message:
[E 12:38:28.148 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 "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 72, in post
type=mtype))
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/apeiyin/anaconda3/lib/python3.7/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 "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/apeiyin/anaconda3/lib/python3.7/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 "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 240, in start_kernel
self.write_connection_file()
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "/home/apeiyin/anaconda3/lib/python3.7/contextlib.py", line 112, in enter
return next(self.gen)
File "/home/apeiyin/anaconda3/lib/python3.7/site-packages/jupyter_core/paths.py", line 433, in secure_write
.format(file=fname, permissions=oct(file_mode)))
RuntimeError: Permissions assignment failed for secure file: '/home/apeiyin/.local/share/jupyter/runtime/kernel-bac65489-47a6-4406-a220-803b774c6b3b.json'.Got '0o677' instead of '0o0600'
[W 12:38:28.192 NotebookApp] Unhandled error
[E 12:38:28.196 NotebookApp] {
"Host": "localhost:8888",
"Connection": "keep-alive",
"Content-Length": "74",
"Accept": "application/json, text/javascript, /; q=0.01",
"X-Requested-With": "XMLHttpRequest",
"X-Xsrftoken": "2|578441d1|2fac94d7fe5d19db349d3a7cbc33325a|1592146979",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
"Content-Type": "application/json",
"Origin": "http://localhost:8888",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "http://localhost:8888/notebooks/Untitled.ipynb",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"Cookie": "_xsrf=2|578441d1|2fac94d7fe5d19db349d3a7cbc33325a|1592146979; username-localhost-8888="2|1:0|10:1592282303|23:username-localhost-8888|44:ZDhmNzZjNDVmYTA4NDlhNGIxN2RlNTVhYWY4M2ZiNjY=|6f2ea57ab00b94c1362b7826f19eb9b6fe22c060e20fde7020247432ce08495f""
}
[E 12:38:28.211 NotebookApp] 500 POST /api/sessions (127.0.0.1) 200.79ms referer=http://localhost:8888/notebooks/Untitled.ipynb

@kevin-bates
Copy link
Member

Hi @angrosamund.

This information, coupled with the information provided on #5535, implies that your home directory is actually coming from a mounted filesystem. In this case, based on the way the filesystem is mounted or its type, applications are unable to affect file permissions - which results in the inability of the framework to write files securely. There are typically 3 choices at this point:

  1. If security is not a concern or you know you're operating within a trusted environment, then you can set the environment variable JUPYTER_ALLOW_INSECURE_WRITES=1 and restart your Notebook server process. This instructs jupyter_core.secure_write() to bypass permission enforcement.
  2. If security is a concern, you can set the environment variable JUPYTER_RUNTIME_DIR=/directory/not/in/mounted/filesystem to a directory path that is NOT within this mounted filesystem and restart your Notebook server process. This will create the kernel connection files in that location, presumably where appropriate permissions can be then be manipulated by secure_write(). In this case, you do not need to set JUPYTER_ALLOW_INSECURE_WRITES=1.
  3. Contact your administrator that configured your filesystem mount strategy and ask them to check various mount options as some require additional configuration to preserve ownership and permission behaviors.

Once the system believes its written a trusted connection file, you should be moving forward again.

@angrosamund
Copy link
Author

@kevin-bates i set the environment variable export JUPYTER_RUNTIME_DIR=/tmp and it worked, thank you for your help!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants