添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Jupyter。在spyder/jupyter笔记本中启动内核时出现拒绝访问的错误

1 人关注

在anaconda,特别是spyder更新到4.0.1之后,spyder和jupyter不再能够启动内核,给出的错误附在下面(在更新之前一切工作正常)。

我试着以管理员身份运行anaconda、jupyter和spyder。我重新安装了所有Anaconda组件和Anaconda本身。我也重启了我的电脑几次。Windows 7。

The error from 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.')

The error from 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
Veryname
Veryname
发布于 2020-01-27
2 个回答
dartagan
dartagan
发布于 2021-10-21
已采纳
0 人赞同

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

从我所知道的来看。Jupyter试图在我们的用户文件夹中设置一个文件的权限(例如 C:\Users\user.name\AppData\Roaming\jupyter )。 由于某些原因,我们没有权限编辑这个文件夹中的文件的权限--因此Jupyter也没有权限,它就失败了。 我们可以通过告诉Jupyter允许这些文件为 "不安全 "来解决这个问题。 在你的命令提示符中,在激活你的环境后,在启动Jupyter之前,这样做。

set JUPYTER_ALLOW_INSECURE_WRITES=1

Then:

jupyter notebook

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

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

Ole J. Forsberg
Ole J. Forsberg
发布于 2021-10-21
0 人赞同

这个问题也让我陷入了僵局。经过几个小时对这个问题和其他解决方案的研究,我从其他地方找到了解决方案。然而,为了使这个问题更加明显,这里是为那些来到这里的人准备的。请注意,这与上面dartagan的解决方案非常相似。

我设置了一个全局环境变量。在我们的网络上,这对每个用户-电脑组合都有效。因此,如果一个学生换了电脑,这个学生就需要重新应用这个解决方案。

  • Find where to set global environment variables in Windows (a search on the computer will show it quickly)
  •