summaryrefslogtreecommitdiff
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index 08c8750c21..ebc2a695f7 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -74,13 +74,22 @@ FilePath detectPython(const FilePath &documentPath)
if (defaultInterpreter.exists())
return defaultInterpreter;
- const FilePath python3FromPath = env.searchInPath("python3");
- if (python3FromPath.exists())
- return python3FromPath;
+ auto pythonFromPath = [=](const QString toCheck) {
+ for (const FilePath &python : env.findAllInPath(toCheck)) {
+ // Windows creates empty redirector files that may interfere
+ if (python.exists() && python.osType() == OsTypeWindows && python.fileSize() != 0)
+ return python;
+ }
+ return FilePath();
+ };
+
+ const FilePath fromPath3 = pythonFromPath("python3");
+ if (fromPath3.exists())
+ return fromPath3;
- const FilePath pythonFromPath = env.searchInPath("python");
- if (pythonFromPath.exists())
- return pythonFromPath;
+ const FilePath fromPath = pythonFromPath("python");
+ if (fromPath.exists())
+ return fromPath;
return PythonSettings::interpreters().value(0).command;
}