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

2022-02-09 Thread Arshad Noman
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
python-uk@python.org
https://mail.python.org/mailman/listinfo/python-uk


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

2022-02-09 Thread SW

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
python-uk@python.org
https://mail.python.org/mailman/listinfo/python-uk
___
python-uk mailing list
python-uk@python.org
https://mail.python.org/mailman/listinfo/python-uk


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

2022-02-09 Thread Jonathan Hartley
You might consider the idea that a script which modifies the spreadsheet should 
read from one file, and write to a different one. This might not fit your 
scenario, but if it does, then the write will never encounter the locking 
exception.

On Wed, Feb 9, 2022, at 03:58, SW wrote:
> 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
>> python-uk@python.org
>> https://mail.python.org/mailman/listinfo/python-uk
>> 
> 
> ___
> python-uk mailing list
> python-uk@python.org
> https://mail.python.org/mailman/listinfo/python-uk
> 

--
Jonathan Hartley  USA, Central(UTC-6)
twitter:@tartley  https://tartley.com___
python-uk mailing list
python-uk@python.org
https://mail.python.org/mailman/listinfo/python-uk