簡體   English   中英

Jupyter:在 spyder / jupyter notebook 中啟動內核時訪問被拒絕錯誤

[英]Jupyter: Access denied error when starting kernel in spyder / jupyter notebook

在 anaconda 中“更新 -all”,特別是 spyder 到 4.0.1 之后,spyder 和 jupyter 不再能夠啟動內核,因為下面附加的錯誤(在更新之前一切正常)。

我試過以管理員身份運行 anaconda、jupyter 和 spyder。 我已經單獨重新安裝了所有 anaconda 組件和 anaconda 本身。 我也重新啟動了我的電腦幾次。 Windows 7的。

來自 jupyter 筆記本的錯誤:

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.')

我在 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

這個問題也讓我很頭疼。 在對這個和其他解決方案進行了幾個小時的研究后,我從其他地方找到了解決方案。 然而,為了讓這更明顯,這里是為那些來這里的人准備的。 請注意,這與上面 dartagan 的解決方案非常相似。

我設置了一個全局環境變量。 在我們的網絡上,這適用於每個用戶-計算機組合。 因此,如果學生更換計算機,則該學生將需要重新應用該解決方案。

  1. 查找在Windows中設置全局環境變量的位置(在計算機上搜索會很快顯示出來)
  2. 創建一個名為 JUPYTER_ALLOW_INSECURE_WRITES 的新變量
  3. 將此變量的值設置為 1

就這樣。

如果是,我希望聽到為什么這個解決方案有問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM