pytesseract.pytesseract.TesseractNotFoundError - image_to_string

Hi, I am doing image processing hence using opencv-tesseract
But when I deploy the app it says

pytesseract.pytesseract.TesseractNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script
    exec(code, module.__dict__)File "/mount/src/anpr_tera/main.py", line 80, in <module>
    main()File "/mount/src/anpr_tera/main.py", line 74, in main
    text = pytesseract.image_to_string(Cropped_img_loc,lang='eng')File "/home/adminuser/venv/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 423, in image_to_string
    return {File "/home/adminuser/venv/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 426, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),File "/home/adminuser/venv/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 288, in run_and_get_output
    run_tesseract(**kwargs)File "/home/adminuser/venv/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 260, in run_tesseract
    raise TesseractNotFoundError()

code :
text = pytesseract.image_to_string(Cropped_img_loc,lang=‘eng’)

Please share a link to your public github repo.
Either the tesseract binary is not installed or could not be found by pytesseract.
If tesseract binary is installed and it still does not work, try this code snippet:

import pytesseract
import shutil
import streamlit as st

pytesseract.pytesseract.tesseract_cmd = None

# search for tesseract binary in path
@st.cache_resource
def find_tesseract_binary() -> str:
    return shutil.which("tesseract")

# set tesseract binary path
pytesseract.pytesseract.tesseract_cmd = find_tesseract_binary()
if not pytesseract.pytesseract.tesseract_cmd:
    st.error("Tesseract binary not found in PATH. Please install Tesseract.")
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.