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

MRAB google at mrabarnett.plus.com
Mon Jan 26 11:07:39 EST 2009


Jay Jesus Amorin wrote:
 > Hi,
 >
 > Kindly help, I've got this error when running my script:
 >
 > AttributeError: 'module' object has no attribute 'open_workbook'
 >
 >
 > Here's my code:
 >
 > #!/usr/bin/python
 >
 > import xlrd
 > import sys
 >
 > mySpreadsheet = xlrd.open_workbook(open(sys.argv[1]))
 > firstSheet = wb.sheet_by_index(0)
 >
 > for myRows in range(sh.nrows):
 >     print firstSheet.row_values(myRows)
 >
 >
 > Here's the error message:
 >
 > root at nebuchadnezzar:/home/test/project# ./xlrd.py test.xls
 > Traceback (most recent call last):
 >   File "./xlrd.py", line 3, in <module>
 >     import xlrd
 >   File "/home/jayam/project/xlrd.py", line 6, in <module>
 >     mySpreadsheet = xlrd.open_workbook(open(sys.argv[1]))
 > AttributeError: 'module' object has no attribute 'open_workbook'
 >
 From the traceback it looks like your script is called "xlrd.py", which
is the same name as the module "xlrd" that it's importing. If that's the
case, rename your script.



More information about the Python-list mailing list