Ask a Question

Unable read excel file with xlrd package

New Contributor

Unable read excel file with xlrd package

Hi: I wrote a code in python to read excel file (.xlsx).


Used the import package xlrd. Placed the appropriate package in C:\Program Files (x86)\SmartBear\TestComplete 11\Bin\Extensions\Python\Python34\Lib


import xlrd code works fine but Test complete doesnot recognize attribute open_workbook.


Code works fine in Python IDLE but Test Complete does not recognize this attribute.  


def xlrd_package_check():
import xlrd

# The above line has issue
# print number of sheets
# print sheet names
# get the first worksheet
first_sheet = book.sheet_by_index(2)
# read a row
# read a cell
cell = first_sheet.cell(0,0)

Community Hero

Re: Unable read excel file with xlrd package



Did you receive any error?


Try to add a path to your package:


from os import sys

sys.path.insert(0, '%PATH_TO_PYTHON_DIRECTORY%\Lib\site-packages')
Community Hero

Re: Unable read excel file with xlrd package

If your code is a direct copy/paste of what you actually have in TC... I'm not a Python coder, but your path...  Are you missing some backslash characters?  IIRC, Python, like JavaScript, requires the backslash to be doubled to be recognized.  The problem might not be in the package but in your path.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
New Contributor

Re: Unable read excel file with xlrd package

Hi Baxatob:


Yes  Iam receiving an error 


AttributeError 'module' object has no attribute 'load_workbook' Error location: Unit: "pythoncode\pythonworks\Script\Unit1" Line: 39 Column: 1.

'module' object has no attribute 'load_workbook'


THanks for your help adding the python path helps with execution of code.


But do i have to install Python in all system where i execute the Test Complete Code. 

I have few systems with Test Execute and I don't have Python IDLE installed there.



Community Hero

Re: Unable read excel file with xlrd package



Glad to hear that it helps.

You don't need to install Python, because TestComplete/TestExecute already go with Python interpreter. However you need to install your third-party package. Usually we do it using pip-installer, which is a part of a standard Python installation. But pip is not included into TC/TE installation.


So you can:
- automatically install the standard Python with pip module, then install your package using 'pip install' command, and finally assign the system path to it;
- manually install pip in TC/TE Python directory, then automatically install your package using 'pip install' command;
- manually install your package in TC/TE Python directory.


[!] Manual installation of Python libraries is not trivial and requires some attention and understanding of what you do, but all of these procedures are well documented -


Showing results for 
Search instead for 
Did you mean: