I have this code:
try:
from PIL import Image as Img
import os
import pytesseract as tss
except ImportError as error:
raise Exception(str(e))
from passporteye import read_mrz
#So far you're using windows always do this; esp. if you've haven't add teseract.exe to PATH
#tesseract_cmd=r'C:\Program Files (x86)\Tesseract-OCR'
def Get_mrz(image_file):
print("This will take a while.")
try:
mrz=read_mrz(image_file,save_roi=True)
print("Done")
except Exception as e:
raise Exception("THERE WAS AN EXCEPTION "+str(e))
if mrz!=None:
print(mrz)
else:
return "Cannot read text"
def Credits():
print("This is work...")
#The test is below
Get_mrz("img/id_card2f.jpg")
Credits()
It keeps giving this error:
Traceback (most recent call last):
File "main_stuff.py", line 28, in <module>
Get_mrz("img/id_card2f.jpg")
File "main_stuff.py", line 18, in Get_mrz
raise Exception("THERE WAS AN EXCEPTION "+str(e))
Exception: THERE WAS AN EXCEPTION tesseract is not installed or it's not in your PATH. See README file for more information.
but I dont know why.Tesseract-ocr binary was succesfully installed and added to my PATH.
I know this because if I run tesseract --version
in any directory it gives
tesseract v5.0.0-alpha.20200328
leptonica-1.78.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found FMA
Found SSE
Found libarchive 3.3.2 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5
Found libcurl/7.59.0 OpenSSL/1.0.2o (WinSSL) zlib/1.2.11 WinIDN libssh2/1.7.0 nghttp2/1.31.0