From de7df88ce3ca1bb250d1eecdf3175f68d8074e38 Mon Sep 17 00:00:00 2001 From: jim800121chen Date: Mon, 23 Mar 2026 12:45:34 +0800 Subject: [PATCH] fix: detect Windows App Alias fake python in install script Windows 10/11 ships with App Execution Aliases that redirect python.exe to Microsoft Store. The installer now detects this stub and provides specific guidance to install real Python and disable the alias. Co-Authored-By: Claude Opus 4.6 (1M context) --- edge-ai-platform/scripts/install.ps1 | 37 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/edge-ai-platform/scripts/install.ps1 b/edge-ai-platform/scripts/install.ps1 index c1475d8..3caba7e 100644 --- a/edge-ai-platform/scripts/install.ps1 +++ b/edge-ai-platform/scripts/install.ps1 @@ -134,19 +134,38 @@ if ($libusbFound) { Write-Step "3/5 Setting up Kneron hardware environment" $pythonCmd = $null -# Try python3 first, then python (Windows often uses 'python' for Python 3) -if (Get-Command python3 -ErrorAction SilentlyContinue) { +# Helper: check if a python command is a real install (not Windows Store App Alias) +function Test-RealPython($cmd) { + $cmdInfo = Get-Command $cmd -ErrorAction SilentlyContinue + if (-not $cmdInfo) { return $false } + # Windows App Alias lives under WindowsApps — it's a stub, not real Python + if ($cmdInfo.Source -match 'WindowsApps') { return $false } + try { + $ver = & $cmd --version 2>&1 + if ($ver -match "Python 3") { return $true } + } catch {} + return $false +} + +if (Test-RealPython "python3") { $pythonCmd = "python3" -} elseif (Get-Command python -ErrorAction SilentlyContinue) { - $pyVer = & python --version 2>&1 - if ($pyVer -match "Python 3") { - $pythonCmd = "python" - } +} elseif (Test-RealPython "python") { + $pythonCmd = "python" } if (-not $pythonCmd) { - Write-Warn "Python 3 not found. Skipping Kneron hardware setup." - Write-Warn " Install: winget install Python.Python.3.12" + # Detect App Alias to give a more specific hint + $storeAlias = Get-Command python -ErrorAction SilentlyContinue + if ($storeAlias -and $storeAlias.Source -match 'WindowsApps') { + Write-Warn "Detected Windows Store App Alias for Python (not a real installation)." + Write-Warn " Please install Python and ensure the App Alias is disabled:" + Write-Warn " 1. Run: winget install Python.Python.3.12" + Write-Warn " 2. Settings > Apps > Advanced app settings > App execution aliases" + Write-Warn " -> Turn OFF 'python.exe' and 'python3.exe'" + } else { + Write-Warn "Python 3 not found. Skipping Kneron hardware setup." + Write-Warn " Install: winget install Python.Python.3.12" + } } else { $pyVersion = & $pythonCmd --version 2>&1 Write-Info "Python: $pyVersion"