Forum Discussion

Afreen's avatar
Afreen
New Contributor
7 hours ago

Sys, Log not defined. getting nnnnNameError

i m using two files. Both the files create via right click on Script>new item>gave a name thn OK

Unit1 is a file

Unit2 is another

created a function in Unit1 and it has simple 'Log.Message('the message')

eg. def check1():

          Log.Message('the message')

calling this in file Unit2 after doing an import Unit1

it says. "Log is not defined but if use in same file it is working fine

 

2 Replies

    • Hassan_Ballan's avatar
      Hassan_Ballan
      Icon for Champion Level 3 rankChampion Level 3

      This is expected behavior with newer Python versions used in TestComplete 15.80.

      Starting with Python 3.12+, TestComplete global objects like Log, Sys, and Project are no longer automatically shared across imported script units. Each script unit has its own namespace, so when you import another unit, those global objects are not automatically available in that module, which can result in errors like “Log is not defined.”

      SmartBear explains this change and provides recommended approaches in the documentation here: 
      Working with TestComplete Global Objects in Python 3.13

      If this resolves your scenario, marking it as the solution helps future readers find it quickly.