+ // python 3 was not found let us look for python 2
+#ifdef _WIN32
+ command = python23_call("py -2");
+#else
+ command = python23_call("python2");
+#endif // _WIN32
+ if (!command.empty())
+ return command;
+
+#ifdef _WIN32
+ // python launcher is not installed, let cmd auto check
+ // PATH for a python.exe
+ command = python23_call("python");
+ if (!command.empty())
+ return command;
+
+ //failed, prepare to search PATH manually
+ vector<string> const path = getEnvPath("PATH");
+ lyxerr << "Manually looking for python in PATH ...\n";
+ QString const exeName = "python*";
+#else
+ // python2 does not exists, let us try to find python2.x in PATH
+ // the search is probably broader than required
+ // but we are trying hard to find a valid python binary
+ lyxerr << "Looking for python 2.x ...\n";
+ QString const exeName = "python2*";
+#endif // _WIN32
+
+ for (auto bin : path) {
+ QString const dir = toqstr(bin);
+ string const localdir = dir.toLocal8Bit().constData();
+ QDir qdir(dir);
+ qdir.setFilter(QDir::Files | QDir::Executable);
+ QStringList list = qdir.entryList(QStringList(exeName));
+ for (auto bin2 : list) {
+ string const binary = "\"" + addName(localdir,
+ bin2.toLocal8Bit().constData()) + "\"";
+ command = python23_call(binary, true);
+ if (!command.empty())
+ return command;