Files
pricing_review/启动造价审核.bat

67 lines
2.1 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 936 >nul
cd /d "%~dp0"
rem 2026-10-11:不再写死个人机 python 路径。查找顺序 = 项目 .venv(exe 或 cmd 垫片)-> py -3 -> python。
rem Windows 商店的 python 占位符会"静默退出"(exit 49),所以每个候选都先探测一次。
set "PY="
if exist ".venv\Scripts\python.exe" set "PY=.venv\Scripts\python.exe"
if not defined PY if exist ".venv\Scripts\python.cmd" set "PY=.venv\Scripts\python.cmd"
if defined PY goto HAVEPY
py -3 -c "import sys" >nul 2>&1
if not errorlevel 1 set "PY=py -3"
if not defined PY (
python -c "import sys" >nul 2>&1
if not errorlevel 1 set "PY=python"
)
if not defined PY goto NOPY
:HAVEPY
if not exist "launch.py" goto NOFILE
rem ---- 依赖预检(2026-10-11 新机部署实证:新机器缺 cryptography 起不来)----
rem 五个依赖全探测,缺任一就提示一键装(requirements.txt 版本全锁定);装齐直接启动。
%PY% -c "import cryptography, httpx, openpyxl, xlrd, webview" >nul 2>&1
if not errorlevel 1 goto DEPOK
echo.
echo 检测到缺少依赖库(首次部署需要联网安装一次,约几十秒)。
set "GO="
set /p GO=现在自动安装吗?直接回车=安装,输入 N 退出:
if /i "%GO%"=="N" goto NODIST
echo 正在安装依赖(%PY% -m pip install -r requirements.txt)...
%PY% -m pip install -r requirements.txt
if errorlevel 1 goto PIPFAIL
echo 依赖安装完成。
:DEPOK
echo 正在启动造价审核,请稍候...
%PY% launch.py
if errorlevel 1 goto FAIL
goto END
:NODIST
echo 已取消。可稍后手动执行:%PY% -m pip install -r requirements.txt
pause
goto END
:PIPFAIL
echo.
echo 依赖安装失败。常见原因:没联网 / Python 太旧。
echo 可手动执行:%PY% -m pip install -r requirements.txt 查看详细报错。
pause
goto END
:FAIL
echo.
echo 启动失败。常见原因:
echo 1. 提示 ModuleNotFoundError 缺依赖 —— 执行: %PY% -m pip install -r requirements.txt
echo 2. 提示授权/激活 —— 商业版门禁属正常,联网激活或联系软件提供方
echo 请把上面的错误信息截图发出来。
pause
goto END
:NOPY
echo 没有找到可用的 Python(需要 3.11 及以上)。
echo 请到 https://www.python.org/downloads/ 安装,安装时勾选 "Add python.exe to PATH",
echo 装完后重新双击本文件。
pause
goto END
:NOFILE
echo 找不到启动文件 launch.py
echo 请确认你在正确的文件夹里运行本文件。
pause
:END