PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

Chris Angelico rosuav at gmail.com
Thu Feb 10 16:11:32 EST 2022


On Fri, 11 Feb 2022 at 07:57, Christian Gollwitzer <auriocus at gmx.de> wrote:
>
> Am 10.02.22 um 20:43 schrieb Chris Angelico:
> > On Fri, 11 Feb 2022 at 06:41, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> >>          While not tested with Excel, I /have/ encountered cases where an
> >> application has locked the file for writing, but multiple readers are
> >> permitted. Those would fail then if one attempts to write. {The other view
> >> point is a library that does a complete open/read\write-all/close to memory
> >> -- such an application might open/read/close, then Excel opens/locks, with
> >> the application only learning of the change when it attempts the
> >> open/write/close cycle}
> >>
> >
> > Yeah, I doubt Excel is that sophisticated. It's built on an assumption
> > of single-user operation.
> >
>
> It guards against multiple user opening the same file over network
> drives. All MS applications create lock files with weird names like
> ~.original-name.xlsx etc. If you open a file on the network share, and a
> colleague tries to open it from a second machine, then he will get the
> message "File locked by user xy from machine z". See here for word:
> https://support.microsoft.com/en-us/topic/-the-document-is-locked-for-editing-by-another-user-error-message-when-you-try-to-open-a-document-in-word-10b92aeb-2e23-25e0-9110-370af6edb638
>

Yeah, but that's still just hard locking, no "one writer multiple
readers" system or anything.

> I believe (haven't tested) that this is cooperative locking only and it
> doesn't help if you alter the file from another program. On the same
> machine though, I think that Excel opens the file with a flag to lock it
> from other processes. At least that was my observation and also what the
> OP has described.
>

That sounds right; and, again, it's just a simple exclusive lock.
Excel doesn't have the sophistication to need or want anything more
than simple "I have this file, nobody else touch it" exclusive
locking.

ChrisA


More information about the Python-list mailing list