Notification texts go here Contact Us Buy Now!

Python error when importing image_to_string from tesseract

If you encounter an error while importing image_to_string from tesseract, it's crucial to verify the syntax and the module installed.

The image_to_string function is a part of the PyTesser module and not python-tesseract. Ensure your import statement aligns with the module you have installed.

If you're using PyTesseract, you can modify the module to use PIL instead of Image:

from pytesseract import image_to_string
from PIL import Image

im = Image.open(r'C:\Users\user\Downloads\dashboard-test.jpeg')
print(image_to_string(im))

Alternatively, you can install the required packages:

pip3 install pytesseract
pip3 install pillow

For Windows users, you may also need to install tesseract-ocr and add the path to the tesseract.exe executable:

from PIL import Image
from pytesseract import image_to_string

print(image_to_string(Image.open('test.tif'),lang='eng'))

If you're still facing issues, try adding the following line to your code:

pytesseract.pytesseract.tesseract_cmd = "C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.