diff --git a/install.bat b/install.bat index a0d17e1..0a04962 100644 --- a/install.bat +++ b/install.bat @@ -178,20 +178,21 @@ if exist "%BOTTY_ENV_DIR%\Library\bin\tesseract.exe" ( echo Renamed broken conda tesseract.exe ) -:: Install working tesseract 5.5.0 via winget (conda version crashes) +:: Install winget tesseract as optional pytesseract fallback. +:: tesserocr (conda DLLs + bundled wheel) is the primary OCR backend and works +:: on both Win10 and Win11 without this step. winget is not guaranteed on Win10 +:: so this is best-effort only — the bot runs fine without it. if not exist "C:\Program Files\Tesseract-OCR\tesseract.exe" ( - echo Installing tesseract-OCR via winget... + echo Installing tesseract-OCR via winget ^(optional pytesseract fallback^)... winget install --id tesseract-ocr.tesseract --silent --accept-package-agreements --accept-source-agreements 2>nul if %errorlevel% neq 0 ( - echo WARNING: winget tesseract install failed. pytesseract may not work. + echo winget not available or install failed -- skipping ^(tesserocr unaffected^) ) ) if exist "C:\Program Files\Tesseract-OCR\tesseract.exe" ( - echo Tesseract OCR found: C:\Program Files\Tesseract-OCR\tesseract.exe + echo Tesseract exe found -- pytesseract fallback is available ) else ( - echo WARNING: Tesseract OCR not found after install attempt. - echo pytesseract gem-count OCR will not work until Tesseract is installed. - echo Download manually from: https://github.com/tesseract-ocr/tesseract/releases + echo Tesseract exe not found -- pytesseract fallback inactive ^(tesserocr is primary^) ) :: Ensure tesseract.dll exists (conda may name it tesseract41.dll) @@ -225,17 +226,6 @@ if exist "dependencies\tesserocr-2.5.2-cp310-cp310-win_amd64.whl" ( exit /b 1 ) -:: Verify pytesseract can locate and call the winget tesseract binary. -:: ocr.py reads PYTESSERACT_TESSERACT_CMD at import time (Bug 14 fix), so no -:: source-patching is needed — we just confirm the chain works end-to-end here. -echo. -echo Verifying pytesseract OCR... -"%CONDA_EXE%" run -n botty python -c "import pytesseract, os; cmd=r'C:\Program Files\Tesseract-OCR\tesseract.exe'; pytesseract.pytesseract.tesseract_cmd=cmd; v=pytesseract.get_tesseract_version(); print(' pytesseract OK: tesseract ' + str(v))" 2>nul -if %errorlevel% neq 0 ( - echo WARNING: pytesseract could not call tesseract. Gem-count OCR will not work. - echo Ensure C:\Program Files\Tesseract-OCR\tesseract.exe exists ^(run as admin^). -) - :: Set PATH for tesseract DLL before testing set "TESS_PATH=%BOTTY_ENV_DIR%\Library\bin;%BOTTY_ENV_DIR%\Library\lib;%BOTTY_ENV_DIR%\DLLs;%BOTTY_ENV_DIR%\Scripts" @@ -243,7 +233,7 @@ set "TESS_PATH=%BOTTY_ENV_DIR%\Library\bin;%BOTTY_ENV_DIR%\Library\lib;%BOTTY_EN echo. echo Verifying all dependencies... set "ALL_OK=1" -for %%M in (cv2 mss numpy tesserocr pytesseract discord transitions rapidfuzz) do ( +for %%M in (cv2 mss numpy tesserocr discord transitions rapidfuzz) do ( set "PATH=%TESS_PATH%;%PATH%" "%CONDA_EXE%" run -n botty python -c "import %%M" >nul 2>&1 if %errorlevel% neq 0 ( @@ -254,6 +244,18 @@ for %%M in (cv2 mss numpy tesserocr pytesseract discord transitions rapidfuzz) d ) ) +:: Smoke-test tesserocr end-to-end: DLL load + tessdata access. +echo. +echo Smoke-testing tesserocr OCR... +set "PATH=%TESS_PATH%;%PATH%" +"%CONDA_EXE%" run -n botty python -c "import sys; sys.path.insert(0,'src'); import os; os.add_dll_directory(r'%BOTTY_ENV_DIR%\Library\bin'); from tesserocr import PyTessBaseAPI, OEM; api=PyTessBaseAPI(psm=7,oem=OEM.LSTM_ONLY,path='assets/tessdata',lang='hover-eng_inconsolata_inv_th_fast'); api.End(); print(' tesserocr OK')" 2>nul +if %errorlevel% neq 0 ( + echo FAILED: tesserocr could not open tessdata model. + echo Item hover OCR and gem-count OCR will not work. + echo Check that conda tesseract DLLs and bundled wheel installed correctly above. + set "ALL_OK=0" +) + if "%ALL_OK%"=="1" ( echo. echo All dependencies verified.