Notebook: Error Starting Jupyter Kernel

Created on 30 Jan 2020  路  9Comments  路  Source: jupyter/notebook

I'm using Jupyter Lab on wsl.
I run the notebooks on Windows Chrome.
The following error is occurring:

Traceback (most recent call last):
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 72, in post
type=mtype))
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "/mnt/c/users/haseeb/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 "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/mnt/c/users/haseeb/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 "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 240, in start_kernel
self.write_connection_file()
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "/mnt/c/users/haseeb/anaconda3/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/mnt/c/users/haseeb/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: '/mnt/c/users/haseeb/.local/share/jupyter/runtime/kernel-155a645a-6d06-42bb-b30a-ad966c7081fc.json'.Got '0o677' instead of '0o0600'

Most helpful comment

Problem solved Sir.
I had exported the variable but that only happened for the current session. Therefore I added the line to export the environment variable in .zsh_rc and the warning started appearing.

Thank you so much Sir, you have been very helpful. You have been delivering incredible value by taking out so much time to help out. Thus this has been a seemingly small but gargantuan-in-essence step towards making our planet better.:)

All 9 comments

Hi @dialzen - this looks like a duplicate of #5058. In particular, please refer to this comment of the issue. If the provided workaround is not viable, you'll likely need to look into the NFS settings for that mount. (Of course, if this isn't related to NFS at all, that would be good to know as well.)

I'm just a beginner at Jupyter and I do not have any know-how of how servers work. The answer you suggested pertains to some server side issue which I am having difficulty comprehending. Plus, that issue doesn't seem to resemble my issue at all, or so I think. That's because I'm running Jupyter Lab on Windows Subsystem for linux on Windows 10. I run the jupyter script and then copy the notebook link and open chrome to run it and this is what shows up. Kindly suggest a workaround I will be able to work on.

Understood. Yes, this is an issue with the server and you might need to enlist the help of a colleague, if available. The issue is that the mounted filesystem, used by WSL, is currently configured to set all file permission bits on files. The file that is being created when a kernel (notebook) is launched is considered secure (because it contains connection information) and the Jupyter code is trying to protect the file, but can't due to the filesystem behavior.

I believe there are two forms of work around here...

  1. You can point your Jupyter runtime directory to a different location by setting JUPYTER_RUNTIME_DIR to a different location that doesn't reside in the filesystem. However, I'm not familiar enough with Windows and WSL to know the best approach for that.
  2. You can upgrade juptyer_core to its recent 4.6.2 release (pip install jupyter_core --upgrade), then set environment variable JUPYTER_ALLOW_INSECURE_WRITES=True. This should only be done with your consent because it will allow the insecure file to persist for the duration of the notebook kernel.

In either case, some level of server-side operations are required, so you might need to enlist the help of someone familiar with these kinds of operations.

I am sorry I can not enlist help from a colleague. I tried to look up changing environment variables in Jupyter but could not find any sound explanation.

I updated Jupyter_core but afterwards couldn't find a way to set INSECURE_WRITES to True. Kindly suggest a way to change these variables.

hi @dialzen - Here's a blog post for how to setup system environment variables on Windows 10. You should logout and back in again so that all windows (cmd shells, etc.) contain the new value. If that's not possible right now, then create a new command window in which to start your notebook server.

The variable you want to set must be complete and is JUPYTER_ALLOW_INSECURE_WRITES and its value should be set to true. Case matters for the variable name, but not for the value. To confirm the environment variable is in place, enter $env:JUPYTER_ALLOW_INSECURE_WRITES (per the blog post) in a new command shell and ensure it displays the appropriate value.

Once the variable is in place, restart notebook from a command window that has the environment variable. If you start notebook using some other mechanism, then logging out and back in should make the environment variable available to that start mechanism as well.

I updated the Windows 10 variable and it did not seem to have any effect on wsl bash. Afterwards I learnt how to change environment variables for linux. So I did this in a bash window: export JUPUTER_ALLOW_INSECURE_WRITES=True
However the same error persists.

Was this done in the same command window and before you started notebook?

On startup, and assuming the env variable is in place, you should see a warning message when starting notebook, similar to the following:

WARNING: Insecure writes have been enabled via environment variable 'JUPYTER_ALLOW_INSECURE_WRITES'! If this is not intended, remove the variable or set its value to 'False'.

Could you please confirm you see this warning?

Problem solved Sir.
I had exported the variable but that only happened for the current session. Therefore I added the line to export the environment variable in .zsh_rc and the warning started appearing.

Thank you so much Sir, you have been very helpful. You have been delivering incredible value by taking out so much time to help out. Thus this has been a seemingly small but gargantuan-in-essence step towards making our planet better.:)

Hi @dialzen - your words are very kind - thank you. Welcome to the Jupyter community!

Was this page helpful?
0 / 5 - 0 ratings