fix python version check to correctly detect the version and handle commands that don't exist
@@ -177,13 +177,16 @@ PYTHON=
for PYTHON_EXECUTABLE in python python3 python3.6 python3.7
do
# Get exact version of python interpreter
- HAVE=$(${PYTHON_EXECUTABLE} --version 2> null | awk '{ print $2 }')
+ possible_python=$(which ${PYTHON_EXECUTABLE})
+ if [ -n "$possible_python" ]; then
+ HAVE=$(${possible_python} --version 2>&1 | awk '{ print $2 }')
# Stop if version is new enough
if echo -e "${HAVE}\n3.6" | sort -V | head -1 | grep "^3.6$"
then
- PYTHON=$(which ${PYTHON_EXECUTABLE})
+ PYTHON=${possible_python}
break
fi
+ fi
done
if [ -z "${PYTHON}" ]
then
