From 63df3090d5cecf870a53a3300b8630429063626a Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 4 Oct 2015 12:09:10 +0300 Subject: [PATCH] Fix python detection when the 'Anaconda' software is installed. Closes #3731. --- src/core/utils/misc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/utils/misc.cpp b/src/core/utils/misc.cpp index 1202dbfb9..fdc2a0a73 100644 --- a/src/core/utils/misc.cpp +++ b/src/core/utils/misc.cpp @@ -300,9 +300,15 @@ QString Utils::Misc::pythonVersionComplete() { QByteArray output = pythonProc.readAllStandardOutput(); if (output.isEmpty()) output = pythonProc.readAllStandardError(); - const QByteArray versionStr = output.split(' ').last(); - version = versionStr.trimmed(); - Logger::instance()->addMessage(QCoreApplication::translate("misc", "Python version: %1").arg(version), Log::INFO); + + // Software 'Anaconda' installs its own python interpreter + // and `python --version` returns a string like this: + // `Python 3.4.3 :: Anaconda 2.3.0 (64-bit)` + const QList verSplit = output.split(' '); + if (verSplit.size() > 1) { + version = verSplit.at(1).trimmed(); + Logger::instance()->addMessage(QCoreApplication::translate("misc", "Python version: %1").arg(version), Log::INFO); + } } } return version;