Hi! I fixed the code. This code snippet runs in a seperate thread: PyObject *dict=NULL; PyGILState_STATE state = PyGILState_Ensure(); dict = CreateMyGlobalDictionary(); PyRun_String(<my code>, Py_file_input, dict, dict); ReleaseGlobalDictionary(dict); But it still does not work... :-/