AttributeError: module 'xlrd' has no attribute 'open_workbook'

64 Views Asked by At

I am trying to process Excel 97 .XLS file using xlrd library in Python. My code looks like this

import xlrd

def load_xls():
   with xlrd.open_workbook('abc.xls') as wb:       
     for row in range(wb.nrows):
        for col in range(wb.ncols):
           cellValue = wb.cell_value(row, col)
           print (cellValue)

The code results in

AttributeError: module 'xlrd' has no attribute 'open_workbook' 

My xlrd version is 2.0.1

1

There are 1 best solutions below

0
Hemant Satam On

Based on various comments posted, I did use an interpreter to perform the following commands

import xlrd
dir(xlrd)

This displayed the functions available within xlrd, which led me to find out that it was referring to a local file which, I had named xlrd.py

Renamed the file with another name and it resolved the issues - basically it was referring to a local file instead of xlrd lib installed