Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

excel

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.

like image 471
Eline Avatar asked Oct 15 '25 09:10

Eline


2 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.

like image 165
Gul Saeed Khattak Avatar answered Oct 16 '25 21:10

Gul Saeed Khattak


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

like image 42
Rahul Avatar answered Oct 16 '25 21:10

Rahul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!