How to fix [Errno13] permission denied when trying to read excel file?

Viewed 17966

I tried the following code to be able to read an excel file from my personal computer.

import xlrd

book = xlrd.open_workbook('C:\\Users\eline\Documents\***\***\Python', 'Example 1.xlsx')

But I am getting the error 'Permission denied'. I am using windows and if I look at the properties of the directory and look at the 'Security' tab I have three groups/users and all three have permissions for all the authorities, except for the last option which is called 'special authorities' (as far as I know I do not need this authority to read the excel file in Python).

I have no idea how to fix this error. Furthermore, I do not have the Excel file open on my computer when running the simulation.

I really hope someone can help me to fix this error.

3 Answers

Sometimes, it is because you try to read the Excel file while it is opened. Close the file in Excel and you are good to go.

I ran into this situation also while reading an Excel file into a data frame. To me it appears that it is a Python and/or Excel bug which we should probably not hide by using os.path.join even if that solves the problem. My situation involved an excel spreadsheet that links cells to another CSV file. If this excel file is freshly opened and open when I try to read it in python, it fails.

Python reads it correctly if I do an unnecessary save of the open Excel file.

Related