Forum Discussion

NisHera's avatar
NisHera
Valued Contributor
5 years ago

Python imported packages

working with TC python I installed external package XlsxWriter.

according to it's documentation following is a simple function...

import xlsxwriter

def aaa():
workbook = xlsxwriter.Workbook('hello_world.xlsx') worksheet = workbook.add_worksheet() worksheet.write('A1', 'Hello world') workbook.close()

which didn't work ....gave me error

Python runtime error.
TypeError: 'module' object is not callable

after much reaserching found following works

from xlsxwriter import Workbook

def aaaa():
  wb = Workbook('abcd.xlsx')
  worksheet = wb.add_worksheet()
  
  worksheet.write('A1','ABCD')
  wb.close()

why is there a defference of calling packages in TC python?

3 Replies

    • NisHera's avatar
      NisHera
      Valued Contributor

      Hi Robert,

      That dosn't specifically explain what I'm asking.

       

      \Nish

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        It does explain how to do so and some of the architecture.

        TestComplete has it's own Python compiler separate from what you have installed on your environment. Because of this, there are going to be some fundamental differences in how Python is utilized by TestComplete.  Keep in mind that TestComplete runs things as "scripts"... so, it's not full Python development... think of it as PythonScript... like the difference between Java and JavaScript.

        I don't know the SPECIFICS of your situation, but perhaps this will help understand why some things may be different.