Skip to content
Advertisement

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

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

import xlrd

book = xlrd.open_workbook('C:\UserselineDocuments******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.

Advertisement

Answer

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

You cannot give path like this to xlrd. path need to be single string.

If you insist you can use os module

import os
book = xlrd.open_workbook(os.path.join('C:\UserselineDocuments******Python', 'Example 1.xlsx'))

[Errno13] permission denied in your case is happening because you want to read folder like a file which is not allowed.

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