Reputation: 33
i have installed the tasseract using
pip install pytesseract
whenever i tried to run this piece of code
from PIL import Image
import pytesseract
im = Image.open('hasan1.jpg')
print (pytesseract.image_to_string(im))
I got these errors.
Traceback (most recent call last):
File "ocr.py", line 34, in <module>
text = pytesseract.image_to_string(Image.open(filename))
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 193, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 111, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
Upvotes: 2
Views: 4581
Reputation: 893
I believe PyTesseract requires you to have the tesseract library installed on your system - PyTesseract is trying to run the command-line interface but it can't find it presumably because you have only installed the python bindings.
If you are on an Ubuntu/Debian-based system, you can try:
sudo apt-get install tesseract-ocr
You can check the Tesseract installation docs for more info: https://tesseract-ocr.github.io/tessdoc/Home.html
Upvotes: 3