pywintypes.error: (50, 'GetFileSecurity', 'The request is not supported.') while using Jupyter Notebook on network drive

pywintypes.error: (50, 'GetFileSecurity', 'The request is not supported.') while using Jupyter Notebook on network drive

我目前正在尝试在网络驱动器上使用 miniconda + jupyter(与 pip 一起安装)的组合,但出现以下错误:

pywintypes.error: (50, 'GetFileSecurity', 'The request is not supported.')

我目前在一家公司工作,因此我们正在处理有关访问权限的一些限制。不幸的是,我只能在网络驱动器上尝试 jupyter,更改本地硬盘驱动器需要我没有的管理员权限。

完整的错误输出:

Traceback (most recent call last):
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\web.py", line 1699, in _execute
   result = await result
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
   yielded = self.gen.throw(*exc_info)  # type: ignore
 File "c:\programs\miniconda3_64\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
   type=mtype))
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
   value = future.result()
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
   yielded = self.gen.throw(*exc_info)  # type: ignore
 File "c:\programs\miniconda3_64\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 "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
   value = future.result()
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
   yielded = self.gen.throw(*exc_info)  # type: ignore
 File "c:\programs\miniconda3_64\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 "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
   value = future.result()
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 209, in wrapper
   yielded = next(result)
 File "c:\programs\miniconda3_64\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
   super(MappingKernelManager, self).start_kernel(**kwargs)
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
   km.start_kernel(**kwargs)
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
   self.write_connection_file()
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
   kernel_name=self.kernel_name
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
   with secure_write(fname) as f:
 File "c:\programs\miniconda3_64\lib\contextlib.py", line 82, in __enter__
   return next(self.gen)
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\connect.py", line 100, in secure_write
   win32_restrict_file_to_user(fname)
 File "c:\programs\miniconda3_64\lib\site-packages\jupyter_client\connect.py", line 61, in win32_restrict_file_to_user
   sd = win32security.GetFileSecurity(fname, win32security.DACL_SECURITY_INFORMATION)
ywintypes.error: (50, 'GetFileSecurity', 'The request is not supported.')

对此类错误有任何想法或经验吗?

对于遇到此问题的任何人,这似乎是由于更新了 jupyter notebook 或任何其他可以更新它的软件包。

解决问题的步骤如下,

pip install jupyter pip install jupyter-client==5.3.1 python -m ipykernel install --user

您遇到的问题可能是由于浏览器的访问权限以及 jupyter lab 对 运行 的访问权限造成的,正如我刚刚痛苦地发现的那样。

我原来的答案可以在这里找到:https://github.com/jupyter/jupyter_client/issues/481

但是对于那些想继续使用最新的 Jupyter lab/Notebook 版本的其他人来说,这是我的故事:

(我 运行 Anconda 预装了 Jupyter):

1- 使用此命令检查环境路径时:jupyter --paths 我得到两个漫游位置,一个用于 运行时间和数据!这是因为我使用公司笔记本电脑并且 Windows 设置为将用户数据文件存储在网络上的漫游位置!

(base) C:\>jupyter --paths
config:
    C:\Users\user_x\.jupyter
    C:\ProgramData\Anaconda3\etc\jupyter
    C:\ProgramData\jupyter
data:
    \A-FILEDATA-P\Profile\use_x\AppData\Roaming\jupyter
    C:\ProgramData\Anaconda3\share\jupyter
    C:\ProgramData\jupyter
runtime:
    \A-FILEDATA-P\Profile\use_x\AppData\Roaming\jupyter\runtime

(base) C:\>

2- 所以,我尝试通过添加修改 C:\Users\user_xxx.jupyter\jupyter_notebook_config.py JUPYTER_RUNTIME_DIR = 'C:\Users\user_x\AppData\Roaming\jupyter\runtime' 但它没有用!

2- 但是,这里要注意:我注意到 jupyter lab 命令会触发一个 "stand alone" Chrome 我有一个可移动的 USB 硬盘!在公司 Windows 设置下,它没有任何权限写入笔记本电脑上的其他文件夹位置,因此出现安全错误!

3- 解决方案是在我的 USB 磁盘上设置两个文件夹,其中找到独立 Chrome 并将环境变量设置为指向这些位置,如下所示:

set JUPYTER_RUNTIME_DIR=D:\jupyter\runtime
set JUPYTER_DATA_DIR=D:\jupyter

4- 唯一的问题是您必须在每个新会话开始时执行这两个命令,因为当您重新启动 Jupyter 实验室时它们不会持续存在!正如@Shongololo 指出的那样,您只能从命令行 运行 其他程序(例如 Spyder)才能读取正确的设置!

如何永久解决这个问题还有待发现。