简体   繁体   中英

tesseract.exe is not installed or it's not in your path

I am using Pytesseract to read a specific part of a PDF. Following is my code to configure tesseract into my code.

pytesseract.pytesseract.tesseract_cmd = os.path.join(cwd, "Tesseract-OCR\\tesseract.exe")

cwd is the same directory where my SplitPDF.py file and the Tesseract-OCR (which contains tesseract.exe) folder are present.

When I execute SplitPDF.py everything works fine and I have my desired output. But the problem occurs when I create SplitPDF.exe (using Pyinstaller) I am getting an error that says tesseract.exe is not installed or it's not in your path.

Following is the complete error:

Traceback (most recent call last): File "site-packages\\pytesseract\\pytesseract.py", line 223, in run_tesseract File "subprocess.py", line 775, in init File "subprocess.py", line 1178, in _execute_child FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tkinter__init__.py", line 1705, in call File "PDF_Splitter.py", line 241, in UploadAction1 pdfsplitbylca(entryString) File "Split_by_LCA_1.py", line 155, in pdfsplitbylca text = pytesseract.image_to_string(im, lang = 'eng') File "site-packages\\pytesseract\\pytesseract.py", line 345, in image_to_string File "site-packages\\pytesseract\\pytesseract.py", line 344, in File "site-packages\\pytesseract\\pytesseract.py", line 253, in run_and_get_output File "site-packages\\pytesseract\\pytesseract.py", line 225, in run_tesseract pytesseract.pytesseract.TesseractNotFoundError: C:\\Users\\VADIRA~1.KAT\\AppData\\Local\\Temp_MEI370202\\Tesseract-OCR\\tesseract.exe is not installed or it's not in your path

Am I not creating the .exe correctly or is there a better way to configure Tesseract?

You should consider using the Pytesseract library (tesseract python library) instead of the executable. I hope this helped. The usage is pretty easy. you will have to install it first but to use

import pytesseract
from PIL import Image

pytesseract.image_to_string(Image.open('image'))

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM