fix: repair incomplete backend environment on start

This commit is contained in:
OLmatter
2026-06-06 17:40:45 +08:00
parent 2f8cc1bf0f
commit db275068bf
3 changed files with 9 additions and 2 deletions
+7
View File
@@ -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
+1 -1
View File
@@ -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 `
+1 -1
View File
@@ -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