--- a/Libraries/swakPythonIntegration/pythonIntegrationFunctionObject.C
+++ b/Libraries/swakPythonIntegration/pythonIntegrationFunctionObject.C
@@ -80,12 +80,14 @@
     initEnvironment(t);
 
     {
+        setInterpreter();
         PyObject *m = PyImport_AddModule("__main__");
         PyObject_SetAttrString(
             m,
             "functionObjectName",
             PyString_FromString(this->name().c_str())
         );
+        releaseInterpreter();
     }
 
     setRunTime();