From a77dafaf08ee4a3df25ec99a5b249a7723be83a8 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 24 May 2026 14:10:00 +0200 Subject: [PATCH] fix: set conda DLL PATH at batch level before Python starts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit os.environ['PATH'] set from inside Python does not affect the Windows DLL loader used by ctypes.WinDLL — the loader reads the process PATH at load time, not from Python's env dict. Set PATH in the .bat files before python.exe is launched so tesseract51.dll's transitive deps (leptonica, zlib, libpng, etc.) are findable by the loader. Co-Authored-By: Claude Sonnet 4.6 --- install.bat | 7 +++++++ run_botty.bat | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/install.bat b/install.bat index e0d45b8..fdb309a 100644 --- a/install.bat +++ b/install.bat @@ -91,6 +91,13 @@ exit /b 1 :env_created echo Botty Python: %PYTHON% +:: Prepend conda DLL dirs to PATH at the process level so the Windows DLL +:: loader finds tesseract51.dll's transitive deps (leptonica, zlib, etc.) +:: when ctypes loads it. os.environ['PATH'] set from inside Python is too late. +for %%F in ("%PYTHON%") do set "_CONDA_ENV=%%~dpF" +set "_CONDA_ENV=%_CONDA_ENV:~0,-1%" +set "PATH=%_CONDA_ENV%\Library\bin;%_CONDA_ENV%\Library\mingw-w64\bin;%_CONDA_ENV%\Library\usr\bin;%PATH%" + :: --- Force-reinstall the tesserocr wheel so the correct binary is always used --- echo. echo Installing tesserocr wheel... diff --git a/run_botty.bat b/run_botty.bat index 4e8c8c0..1d867a4 100644 --- a/run_botty.bat +++ b/run_botty.bat @@ -5,6 +5,13 @@ cd /d "%BOTTY_DIR%" call "%BOTTY_DIR%find_python.bat" +:: Prepend conda DLL dirs to PATH at the process level so the Windows DLL +:: loader finds tesseract51.dll's transitive deps (leptonica, zlib, etc.) +:: when ctypes loads it. os.environ['PATH'] set from inside Python is too late. +for %%F in ("%PYTHON%") do set "_CONDA_ENV=%%~dpF" +set "_CONDA_ENV=%_CONDA_ENV:~0,-1%" +set "PATH=%_CONDA_ENV%\Library\bin;%_CONDA_ENV%\Library\mingw-w64\bin;%_CONDA_ENV%\Library\usr\bin;%PATH%" + echo Launching Botty ... %PYTHON% "%BOTTY_DIR%src\main.py" pause