Skip to content

Commit ca10a5e

Browse files
committed
Set PYTHONPATH before run python script
1 parent 775786c commit ca10a5e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/plugins/Sea5kg/Python3Scripting/src/Sea5kgPython3Scripting_editorplugin.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,20 @@ void Sea5kgPython3Scripting_editorplugin::runPythonScript(ModelExtension *pModel
317317
QString sPythonHome = QCoreApplication::applicationDirPath() + "/plugins/Sea5kg/Python3Scripting/Python3Home/";
318318
log_info("PYTHONHOME=" + sPythonHome);
319319
qputenv("PYTHONHOME", sPythonHome.toLatin1());
320+
321+
// https://docs.python.org/3/using/cmdline.html
322+
320323
log_info("PYTHONUNBUFFERED=1");
321324
qputenv("PYTHONUNBUFFERED", "1");
325+
log_info("PYTHONUSERBASE=1");
326+
qputenv("PYTHONUSERBASE", "1");
327+
328+
329+
// QString sLdLibraryPath = QString(qgetenv("LD_LIBRARY_PATH"));
330+
QString sPythonPath = "";
331+
sPythonPath += QCoreApplication::applicationDirPath() + "/plugins/Sea5kg/Python3Scripting/Python3Home/lib/python3.10/lib-dynload/" + ":";
332+
sPythonPath += QCoreApplication::applicationDirPath() + "/plugins/Sea5kg/Python3Scripting/Python3Home/" + ":";
333+
qputenv("PYTHONPATH", sPythonPath.toLatin1());
322334

323335
// QProcessEnvironment proc
324336

0 commit comments

Comments
 (0)