From db275068bfc8bb788d6370349748396f876cd09c Mon Sep 17 00:00:00 2001 From: OLmatter Date: Sat, 6 Jun 2026 17:40:45 +0800 Subject: [PATCH] fix: repair incomplete backend environment on start --- scripts/one_click_start.ps1 | 7 +++++++ scripts/start_backend.ps1 | 2 +- start-backend.cmd | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/one_click_start.ps1 b/scripts/one_click_start.ps1 index 5fc289b..ccc09c4 100644 --- a/scripts/one_click_start.ps1 +++ b/scripts/one_click_start.ps1 @@ -54,15 +54,22 @@ $GpuPython = Join-Path $Root ".venv_paddle_gpu\Scripts\python.exe" $ImportCode = "import ultralytics, paddleocr, paddlex, cv2, PIL, numpy" $Ready = $false +$SelectedPython = "" if ($Selected -eq "gpu") { + $SelectedPython = $GpuPython $Ready = Test-PythonImports $GpuPython $ImportCode } else { + $SelectedPython = $CpuPython $Ready = Test-PythonImports $CpuPython $ImportCode } if (-not $Ready) { Write-Host "Backend environment is missing or incomplete. Installing $Selected environment..." $argsList = @("-Target", $Selected) + if ($SelectedPython -and (Test-Path $SelectedPython)) { + Write-Host "Existing backend environment failed import checks. Recreating it..." + $argsList += "-Recreate" + } foreach ($arg in $PipArg) { $argsList += "-PipArg" $argsList += $arg diff --git a/scripts/start_backend.ps1 b/scripts/start_backend.ps1 index d70f43c..c1b2bab 100644 --- a/scripts/start_backend.ps1 +++ b/scripts/start_backend.ps1 @@ -40,7 +40,7 @@ function Test-BackendMainPython { $ErrFile = [System.IO.Path]::GetTempFileName() try { $Proc = Start-Process -FilePath $PythonPath ` - -ArgumentList @("-c", "import ultralytics") ` + -ArgumentList @("-c", "import ultralytics, PIL, cv2, numpy") ` -NoNewWindow ` -Wait ` -PassThru ` diff --git a/start-backend.cmd b/start-backend.cmd index 55462b6..b166ede 100644 --- a/start-backend.cmd +++ b/start-backend.cmd @@ -2,5 +2,5 @@ chcp 65001 >nul cd /d "%~dp0" echo Starting GLM Coding Helper backend... -powershell -NoProfile -ExecutionPolicy Bypass -File "scripts\start_backend.ps1" -Mode cpu -Port 8888 +powershell -NoProfile -ExecutionPolicy Bypass -File "scripts\one_click_start.ps1" -Target cpu -Port 8888 pause