diff --git a/src/lib/app/PyTwkApp/PyInterface.cpp b/src/lib/app/PyTwkApp/PyInterface.cpp index 5c775dae6..b84b173e7 100644 --- a/src/lib/app/PyTwkApp/PyInterface.cpp +++ b/src/lib/app/PyTwkApp/PyInterface.cpp @@ -255,6 +255,15 @@ namespace TwkApp void initPython( int argc, char** argv ) { + // PreInitialize Python + // Note: This is necessary for Python to utilize environment variables like PYTHONUTF8 + PyPreConfig preconfig; + PyPreConfig_InitPythonConfig(&preconfig); + PyStatus status=Py_PreInitialize(&preconfig); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + Py_InitializeEx( 1 ); static wchar_t delim = L'\0';