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

SW <[email protected]> Wed, 9 Feb 2022 10:58:30 +0100
Newsgroups gmane.comp.python.org.uk
Message-ID <HE1P190MB014057A3F3878818E6303CEBB82E9@HE1P190MB0140.EURP190.PROD.OUTLOOK.COM>
--===============5896878716150439292==
Content-Type: multipart/alternative;
 boundary="------------uL5PnuhSiS6Qm0uGSGIHqHWZ"
Content-Language: en-US

--------------uL5PnuhSiS6Qm0uGSGIHqHWZ
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Responding to list in case this helps someone else as well:

When you open a file in Window ("when the excel is already open 
following error") there will generally (or maybe always, I don't recall 
precisely) be an exclusive lock taken on the file.
This means that while another application has a file open you'll get 
this sort of error when you try to access the file in any way.

Therefore, the solution is to make sure not to have the file open in 
another application while trying to run your script on it.

For more information you'll want to search for things like "Windows file 
locking".

Thanks,
S

On 09/02/2022 09:42, Arshad Noman wrote:
> When I enter data using Tkinter form in an Excel file when the excel 
> file is closed there is no error but when I enter data using Tkinter 
> form when the excel is already open following error comes:
>
>
>
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "C:\Users\Dani Brothers\Anaconda3\lib\tkinter\__init__.py", line 
> 1705, in __call__
> return self.func(*args)
> File "D:/Python/Book Bank/New folder/PyCharm/Final/Excel.py", line 61, 
> in SaveBook
> workbook.save(filename="BookBank.xlsx")
> File "C:\Users\Dani 
> Brothers\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", 
> line 392, in save
> save_workbook(self, filename)
> File "C:\Users\Dani 
> Brothers\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 
> 291, in save_workbook
> archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
> File "C:\Users\Dani Brothers\Anaconda3\lib\zipfile.py", line 1207, in 
> __init__
> self.fp = io.open(file, filemode)
> PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'
>
>
>
> What to do to correct this error? I have already searched on google 
> search many times but no solution was found.
>
> _______________________________________________
> python-uk mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-uk

--------------uL5PnuhSiS6Qm0uGSGIHqHWZ
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Responding to list in case this helps
      someone else as well:<br>
      <br>
      When you open a file in Window (&quot;<span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">when
        the excel is already open following error&quot;) there will generally
        (or maybe always, I don't recall precisely) be an exclusive lock
        taken on the file.<br>
        This means that while another application has a file open you'll
        get this sort of error when you try to access the file in any
        way.<br>
        <br>
        Therefore, the solution is to make sure not to have the file
        open in another application while trying to run your script on
        it.<br>
        <br>
        For more information you'll want to search for things like
        &quot;Windows file locking&quot;.<br>
        <br>
        Thanks,<br>
        S<br>
      </span><br>
      On 09/02/2022 09:42, Arshad Noman wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CA+0oV2jvW10yViY6Qhc910rvCF0FFxhqSuTMyt+Y6BwCFx2L4Q@mail.gmail.com">
      
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">
            <div class="gmail_quote">
              <div dir="ltr"><span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">When
                  I enter data using Tkinter form in an Excel file when
                  the excel file is closed there is no error but when I
                  enter data using Tkinter form when the excel is
                  already open following error comes:</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">Exception
                  in Tkinter callback</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">Traceback
                  (most recent call last):</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">File
                  &quot;C:\Users\Dani
                  Brothers\Anaconda3\lib\tkinter\__init__.py&quot;, line
                  1705, in __call__</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">return
                  self.func(*args)</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">File
                  &quot;D:/Python/Book Bank/New
                  folder/PyCharm/Final/Excel.py&quot;, line 61, in SaveBook</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">workbook.save(filename=&quot;BookBank.xlsx&quot;)</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">File
                  &quot;C:\Users\Dani
                  Brothers\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py&quot;,
                  line 392, in save</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">save_workbook(self,
                  filename)</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">File
                  &quot;C:\Users\Dani
                  Brothers\Anaconda3\lib\site-packages\openpyxl\writer\excel.py&quot;,
                  line 291, in save_workbook</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">archive
                  = ZipFile(filename, 'w', ZIP_DEFLATED,
                  allowZip64=True)</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">File
                  &quot;C:\Users\Dani Brothers\Anaconda3\lib\zipfile.py&quot;,
                  line 1207, in __init__</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">self.fp
                  = io.open(file, filemode)</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">PermissionError:
                  [Errno 13] Permission denied: 'Abc.xlsx'</span><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">
                <span style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">What
                  to do to correct this error? I have already searched
                  on google search many times but no solution was found.</span><br>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
python-uk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-uk">https://mail.python.org/mailman/listinfo/python-uk</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>

--------------uL5PnuhSiS6Qm0uGSGIHqHWZ--

--===============5896878716150439292==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
python-uk mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-uk

--===============5896878716150439292==--