Skip to content
Advertisement

Why am I getting a “Permission denied error” while trying to read a cell value using openpyxl python?

Error:

self.fp = io.open(file, filemode) PermissionError: [Errno 13] Permission denied: ‘D:gst_filerinvoice_datajan~$Jan05 Miracle gurukrupa.xlsx’

Code:

wb = openpyxl.load_workbook(filename=os.path.abspath(file), read_only=True)
ws = wb.active
cell_val = ws.cell(row=6,column=2)
print(cell_val)

Advertisement

Answer

in addition to the answer with with statement (which is very good):

elf.fp = io.open(file, filemode) PermissionError: [Errno 13] Permission denied: 
'D:gst_filerinvoice_datajan~$Jan05 Miracle gurukrupa.xlsx'

make sure that your file is not used by another process, such as excel app or another program that reads .xlsx

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement