diff --git a/owpengram-server.bat b/owpengram-server.bat index c0db3095..fb2e47d0 100644 --- a/owpengram-server.bat +++ b/owpengram-server.bat @@ -22,6 +22,10 @@ if errorlevel 1 ( ) rem --- Python ------------------------------------------------------------- +rem Just checking "where" isn't enough: on Windows, python.exe / python3.exe +rem can resolve to the Microsoft Store app-execution-alias stub, which sits +rem on PATH but fails as soon as it's actually run instead of launching real +rem Python. Confirm each candidate's --version actually succeeds too. set "PYTHON=" where py >nul 2>&1 if not errorlevel 1 ( @@ -30,7 +34,10 @@ if not errorlevel 1 ( ) if not defined PYTHON ( where python >nul 2>&1 - if not errorlevel 1 set "PYTHON=python" + if not errorlevel 1 ( + python --version >nul 2>&1 + if not errorlevel 1 set "PYTHON=python" + ) ) if not defined PYTHON ( diff --git a/owpengram-server.sh b/owpengram-server.sh index 5c602586..340e6fc0 100644 --- a/owpengram-server.sh +++ b/owpengram-server.sh @@ -24,11 +24,19 @@ else fi # --- Python --------------------------------------------------------------- +# Just checking `command -v` isn't enough: on Windows, `python3` (and +# sometimes `python`) can resolve to the Microsoft Store app-execution-alias +# stub, which exists on PATH but fails as soon as it's actually run instead +# of launching real Python. Validate the version output too. PYTHON="" +PYTHON_VERSION="" for cand in python3 python; do if command -v "$cand" >/dev/null 2>&1; then - PYTHON="$cand" - break + if VER_OUT="$("$cand" --version 2>&1)" && [[ "$VER_OUT" == Python\ 3* ]]; then + PYTHON="$cand" + PYTHON_VERSION="$VER_OUT" + break + fi fi done @@ -37,7 +45,7 @@ if [[ -z "$PYTHON" ]]; then echo " Install it from: https://www.python.org/downloads/" PROBLEMS=1 else - ok "Python found: $("$PYTHON" --version 2>&1) (${PYTHON})" + ok "Python found: ${PYTHON_VERSION} (${PYTHON})" fi # --- Python dependencies ----------------------------------------------------