pywintypes.error: (50, 'GetFileSecurity',

2020-03-26 12:38发布

问题:

I am currently trying to use a combination of miniconda + jupyter (installed with pip) on a network drive and I get the following error:

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

I am currently working in a corporate set-up, so we are working with some limitations regarding access rights. Unfortunately, I can only try jupyter on network drives, changes to the local hard drive requires admin rights which I don't have.

The full error output:

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

Any ideas or experience with this type of error?

回答1:

For anybody having this issue, it seems to be due to updating jupyter notebook, or any other package that can update it.

The steps to fix the issue are the following,

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



回答2:

The problem you have may be due to access rights for the browser as well as for jupyter lab to run as I have painfully just found.

My original answer can be found here: https://github.com/jupyter/jupyter_client/issues/481

But here is my story for others who want to continue to use the latest Jupyter lab/Notebook version:

(I run Anconda which comes pre installed with Jupyter):

1- When checking the environment paths by using this command: jupyter --paths I get two roaming locations one for runtime and one for data! This is because I use a corporate laptop and Windows is setup to store user data files in a roaming location on the network!

(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- So, I tried modifying C:\Users\user_xxx.jupyter\jupyter_notebook_config.py by adding JUPYTER_RUNTIME_DIR = 'C:\Users\user_x\AppData\Roaming\jupyter\runtime' but it did not work!

2- However, Big note here: I noticed that jupyter lab command fire a "stand alone" Chrome I have on a removable usb harddisk! which under the corporate Windows setup does not have any rights to write to other folder location on the laptop, thus the security error!

3- The solution was to setup two folders on my usb disk, where stand alone Chrome is found and set the environment variables to point to those locations like this:

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

4- The only catch is that you have to do these two commands at the start of every new session as they don't persist say when you restart Jupyter lab! and as @Shongololo pointed out you can only run other programs like Spyder from the command line only for it to read the correct settings!

It remains to be found out how this could be resolved permanently.