fix: set conda DLL PATH at batch level before Python starts
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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...
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user