这篇文章最初发表在SuperUser found here上
我在我的电脑上为RHEL系统安装了jupyter notebook,我使用命令pip3 install --user jupyter安装了它,后来由于它不能运行pip3 install --force-reinstall --user jupyter,所以我知道我的jupyter文件存储在我的~/.local/bin目录中。我不是我工作的集群的管理员或超级用户,这就是我安装在~/.local/bin中的原因。现在每当我打开一个jupyter笔记本,打开一个.ipynb文件,内核都停留在‘内核正在启动,请稍候...’直到内核退出。我试着看看浏览器是否影响了它,现在我已经在be 11,Chrome和Edge上尝试过了,它们都做了同样的事情。我不知道是什么阻止了内核加载。
编辑(02-DEC-2019):似乎有一个可能的解决方案详细介绍了here,然而,这些解决方案描述了如何在windows系统上降级,这就是我在基于linux的操作系统上操作。
编辑(03-DEC-2019):进一步调查后,我发现“内核正在启动,请稍候...”Jupyter页面上的消息对应于终端回声:
RuntimeError: Permissions assignment failed for secure file: ':/path/to/user/tmp/jupyter-kernel:/path/to/user/jupyter-kernel/kernel-66b8b6e5-5e4c-4b05-98e9-870a5b431088.json'.Got '0o1600' instead of '0o0600'
这个问题似乎是在github issues page for Jupyter上讨论过的,我试着按照规定去做,把$JUPYTER_RUNTIME_DIR改到一个新的位置,但没有起作用(实际上我试着换到了不同的目录位置),我确保内核.json文件在正确的位置,以及所有的事情。我仍然继续得到相同的错误。我的系统给我的os.name是POSIX,所以我不知道这是否是潜在的问题,因为这个错误是由一个名为paths.py的文件引起的,而且似乎是secure_write()中的问题,下面是代码的一部分:
@contextmanager
def secure_write(fname, binary=False):
"""Opens a file in the most restricted pattern available for
writing content. This limits the file mode to `0o0600` and yields
the resulting opened filed handle.
Parameters
----------
fname : unicode
The path to the file to write
binary: boolean
Indicates that the file is binary
"""
mode = 'wb' if binary else 'w'
open_flag = os.O_CREAT | os.O_WRONLY | os.O_TRUNC
try:
os.remove(fname)
except (IOError, OSError):
# Skip any issues with the file not existing
pass
if os.name == 'nt':
# Python on windows does not respect the group and public bits for chmod, so we need
# to take additional steps to secure the contents.
# Touch file pre-emptively to avoid editing permissions in open files in Windows
fd = os.open(fname, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o0600)
os.close(fd)
open_flag = os.O_WRONLY | os.O_TRUNC
win32_restrict_file_to_user(fname)
with os.fdopen(os.open(fname, open_flag, 0o0600), mode) as f:
if os.name != 'nt':
# Enforce that the file got the requested permissions before writing
file_mode = get_file_mode(fname)
if 0o0600 != file_mode:
raise RuntimeError("Permissions assignment failed for secure file: '{file}'."
"Got '{permissions}' instead of '0o0600'"
.format(file=fname, permissions=oct(file_mode)))
yield f发布于 2020-03-24 05:47:51
一种解决方法-在Jupyter core v4.6.2中,您现在可以将环境变量JUPYTER_ALLOW_INSECURE_WRITES设置为1或true,以禁用此检查
详细信息:https://discourse.jupyter.org/t/jupyter-core-4-6-2-release-with-insure-mode-option/3300
在进行安全性更改之前,最后一个工作版本是jupyter_client==5.3.1
https://stackoverflow.com/questions/59166173
复制相似问题