Access denied for OneDrive files on demand when using python

Victor Steffens 0 Reputation points
2025-02-25T15:25:57.2333333+00:00

Hey Folks I recently face an issue which already gave me headaches for a week+...

Usually, when I tried to access files on my OneDrive which are marked as "on demand" via python, the interpreter used to download the files via internal automatic onedrive-downloads (the usual popup on the lower right corner of the screen)

Since a few days/weeks I'm not able to access my files anymore - I get a WinError 395 telling me that my permission accessing the files is denied. When using the terminal with the same user, no error occurs - doesn't matter if done from VS Code or directly within terminal. Executing both apps with admin-rights gives no other behaviour.

Strange enough... Creating files in OneDrive locations is not a problem at all with python scripts... This behaviour leads me to consider, that the python interpreter is executed with different rights than the actual user executing that script?? Super weird....

Anybody is facing the same issues? It's driving me nuts since I need to handle and reorganize ~100 GB of picture-data for my scientific work and I don't want to (long-time) spam my computer with the whole content.

As a workaround I ofc can store all the files manually first and then do whatever tish I want to do with it before setting the files on demand again... But cmon... ^^ Since it was still working in January, I assume that some weirdo update is now preventing me from accessing my own files... (Yes - I DO "own" the files!)

Any help is much appreciated!!!

Running with python 3.12.9 and fully updated onedrive

OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,368 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiajing Hua-MFST 15,285 Reputation points Microsoft Vendor
    2025-02-26T02:39:24.02+00:00

    Hi @Victor Steffens

    According to your description, this is more related to OneDrive development, I suggest you post a new thread in Microsoft Tech Community --- OneDrive Developer:

    https://techcommunity.microsoft.com/category/onedriveforbusiness/discussions/onedrivedeveloper

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.