diff --git a/install.bat b/install.bat index ef69e4a..99c934a 100644 --- a/install.bat +++ b/install.bat @@ -298,8 +298,27 @@ set "TESS_PATH=%BOTTY_ENV_DIR%\Library\bin;%BOTTY_ENV_DIR%\Library\lib;%BOTTY_EN :: Remove any existing pip/wheel tesserocr "%PYTHON%" -m pip uninstall tesserocr -y >nul 2>&1 -:: conda tesseract 4.x provides leptonica-1.78.0.dll (MSVC) which tesseract52.dll needs -"%CONDA_EXE%" install -n botty "tesseract=4.*" -c conda-forge -y >nul 2>&1 +:: conda tesseract 4.x provides leptonica-1.78.0.dll (MSVC) which tesseract52.dll needs. +:: libdeflate is required explicitly: the libtiff that ships with tesseract 4.x +:: imports libdeflate, and without it the whole chain below fails to load. +"%CONDA_EXE%" install -n botty "tesseract=4.*" libdeflate -c conda-forge -y >nul 2>&1 + +:: libdeflate.dll compatibility alias. +:: THIS IS WHAT MAKES tesserocr WORK. The DLL chain is: +:: tesserocr.pyd -> tesseract52.dll -> leptonica-1.78.0.dll -> tiff.dll -> libdeflate.dll +:: Current conda-forge libdeflate (>=1.20) installs the library as "deflate.dll", +:: but the older tiff.dll from the tesseract=4.x stack still imports the previous +:: name "libdeflate.dll". Nothing provides that name, so tiff.dll fails to load, +:: and every DLL above it in the chain fails with WinError 126 ("The specified +:: module could not be found") -- which surfaced as tesserocr being permanently +:: unavailable and the bot silently falling back to the slower pytesseract. +:: Copying deflate.dll to the old name satisfies the import; the exported symbols +:: are the same library, verified by tesserocr initialising and running real OCR. +if not exist "%BOTTY_ENV_DIR%\Library\bin\libdeflate.dll" ( + if exist "%BOTTY_ENV_DIR%\Library\bin\deflate.dll" ( + copy /y "%BOTTY_ENV_DIR%\Library\bin\deflate.dll" "%BOTTY_ENV_DIR%\Library\bin\libdeflate.dll" >nul + ) +) :: conda tesseract.exe crashes on Win10 and Win11 — disable it, keep the DLLs if exist "%BOTTY_ENV_DIR%\Library\bin\tesseract.exe" (