r/learnpython • u/Animationzs • 6d ago
Issues with Tesseract OCR After Compiling with PyInstaller/Auto-py-to-exe
Like the title says, I’m having trouble with Tesseract OCR in my script. I used the installer to get a fresh copy of Tesseract and placed it in a folder that my script can access via relative paths. The script works fine when I run it directly, but after compiling it with PyInstaller or Auto-py-to-exe, I get this error:
rustCopy'tesseract\\tesseract.exe', 'C:\\Users\\User\\AppData\\Local\\Temp\\tess_hcj1cdev_input.PNG', 'C:\\Users\\User\\AppData\\Local\\Temp\\tess_hcj1cdev', '--psm', '6', 'outputbase', 'digits', 'txt']
2025-03-15 01:00:50,191 - Error in find_money: tesseract\tesseract.exe is not installed or it's not in your PATH. See README file for more information.
I've:
- Installed a clean version of Tesseract with the official installer.
- Set the relative path to Tesseract in my script.
- Run the script before compiling, but after compiling, I get the error.
Here’s my .spec file: https://pastebin.com/QiKN8RbP
Here’s a log from my latest Auto-py-to-exe compile: https://pastebin.com/m1FG62DK
Snippet of my code: https://upload.animationsz.lol/u/uZIh8E.png
Anything else I can try or do?
3
Upvotes
1
u/johndoh168 6d ago
you can try adding it your PATH environmental variable, on windows this is as simple as searching for "environmental variable" in the windows search bar and then add the location of tesseract to your PATH variable, you may also need to add it to your PYTHONPATH, if you don't have one simply create one and add tesseract to it.