Global name 'shared' is not defined

Good morning,

Ignition V7.9.10

We have a global shared script used for calculating uptime on our production lines. This was migrated to another plant (gateway) and we are seeing the error below. If the function is called from a window it works fine. When the same function is called from a Value Changed tag event inside a UDT then the following error is shown in the tag diagnostics window.


This same script package was deployed to two other gateways with the same version and we do not have this issue. I read in an earlier post this was a bug in ignitionIs this still an open issue or is my problem a new one?

Thank you,


com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 16, in valueChanged NameError: global name 'shared' is not defined

at org.python.core.Py.NameError(

at org.python.core.PyFrame.getglobal(

at org.python.pycode._pyx14.valueChanged$1(:18)

at org.python.pycode._pyx14.call_function()



at org.python.core.PyFunction.function___call__(

at org.python.core.PyFunction.__call__(

at org.python.core.PyFunction.__call__(

at org.python.core.PyFunction.__call__(

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(

at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$

at com.inductiveautomation.ignition.common.sqltags.scripts.AbstractTagScript.invoke(

at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$Task.invoke(

at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$

at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$

at java.util.concurrent.Executors$ Source)

at Source)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)

at java.util.concurrent.ScheduledThreadPoolExecutor$ Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$ Source)

at Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File "", line 16, in valueChanged NameError: global name 'shared' is not defined

Have you had any resolution around this? I am now noticing a similar error when trying to call shared scripts from within a custom function of a Gateway Tag Change script.

Try adding “Import shared” above your current code

1 Like

Gateway event scripts use a legacy python scoping mode for backward compatibility. It only loads system, project, shared, etc, in the top level of the event script. If you define any function within the event script, those functions won’t inherit higher level imports, and require the corresponding import inside the function.

I strongly recommend passing your event and associated variables to a project script function. Script modules use modern scope rules.