【问题标题】:Jupyter: Access denied error when starting kernel in spyder / jupyter notebookJupyter:在 spyder / jupyter notebook 中启动内核时访问被拒绝错误
【发布时间】:2020-05-13 00:00:48
【问题描述】:

在 anaconda 中执行“update -all”后,特别是 spyder 到 4.0.1,spyder 和 jupyter 不再能够启动内核,因为下面附加了错误(在更新之前一切正常)。

我尝试以管理员身份运行 anaconda、jupyter 和 spyder。我已经单独重新安装了所有 anaconda 组件和 anaconda 本身。我也多次重启了我的电脑。视窗 7。

来自 jupyter notebook 的错误:

Traceback (most recent call last):
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "D:\Chris\Continuum\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 "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "D:\Chris\Continuum\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 "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
    self.write_connection_file()
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_client\connect.py", line 476, in write_connection_file
    kernel_name=self.kernel_name
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
    with secure_write(fname) as f:
  File "D:\Chris\Continuum\anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_core\paths.py", line 424, in secure_write
    win32_restrict_file_to_user(fname)
  File "D:\Chris\Continuum\anaconda3\lib\site-packages\jupyter_core\paths.py", line 375, in win32_restrict_file_to_user
    win32security.SetFileSecurity(fname, win32security.DACL_SECURITY_INFORMATION, sd)
pywintypes.error: (5, 'SetFileSecurity', 'Access is denied.')

来自 spyder 的错误:

Traceback (most recent call last):
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\spyder\plugins\ipythonconsole\plugin.py", line 1173, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle, **kwargs)
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\jupyter_client\connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "D:\Chris\Continuum\anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\jupyter_core\paths.py", line 424, in secure_write
win32_restrict_file_to_user(fname)
File "D:\Chris\Continuum\anaconda3\lib\site‑packages\jupyter_core\paths.py", line 375, in win32_restrict_file_to_user
win32security.SetFileSecurity(fname, win32security.DACL_SECURITY_INFORMATION, sd)
pywintypes.error: (5, 'SetFileSecurity', 'Access is denied.')

【问题讨论】:

    标签: python jupyter spyder


    【解决方案1】:

    我在 Windows Server 2016 上看到了与最新版本的 jupyter-client 完全相同的错误问题,在启动内核时抛出“访问被拒绝”错误。

    据我所知:Jupyter 正在尝试对我们用户文件夹中的文件设置权限(例如 C:\Users\user.name\AppData\Roaming\jupyter)。并且由于某种原因,我们无权编辑此文件夹中文件的权限 - 因此 Jupyter 也没有权限并且它失败了。可以通过告诉 Jupyter 允许这些文件“不安全”来解决这个问题。在您的命令提示符下,在激活您的环境之后并在启动 Jupyter 之前执行以下操作:

    set JUPYTER_ALLOW_INSECURE_WRITES=1
    

    然后:

    jupyter notebook
    

    现在希望您的内核能够启动。

    这个 GitHub 问题与寻找解决方案最相关:https://github.com/jupyter/notebook/issues/4907#issuecomment-588536184

    【讨论】:

      【解决方案2】:

      这个问题也让我很困扰。在对这个和其他解决方案进行了几个小时的研究之后,我从其他地方找到了解决方案。然而,为了让这一点更加明显,这里是为那些来到这里的人准备的。请注意,这与上述 dartagan 的解决方案非常相似。

      我设置了一个全局环境变量。在我们的网络上,这适用于每个用户-计算机组合。因此,如果学生更换计算机,该学生将需要重新应用解决方案。

      1. 查找在 Windows 中设置全局环境变量的位置(搜索 电脑上会快速显示)
      2. 创建一个名为 JUPYTER_ALLOW_INSECURE_WRITES 的新变量
      3. 将此变量的值设置为 1

      就是这样。

      如果是,我希望知道为什么这个解决方案有问题。

      【讨论】:

        猜你喜欢
        • 2020-02-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-08
        • 2022-12-31
        • 1970-01-01
        相关资源
        最近更新 更多