0

I have a problem with tesseract (I'm working with Pycharm). When I run the script everything is ok. But when I define a method and run it in the terminal, it raises an error:

TesseractNotFoundError: C:\Users\nom_utilisateur\AppData\Local\Tesseract-OCR\tesseract is not installed or it's not in your path

The problem is, why did it show a path that I didn't define in the beginning of the script as tesseract's path? Here is my script's head:

from PIL import Image
import re
import argparse
import cv2
import pytesseract
import numpy as np
from pytesseract import Output
import sys
pytesseract.pytesseract.tesseract_cmd = r'C:/Program Files/Tesseract-OCR/tesseract.exe'

my method:

if __name__ == "__main__":
     img_path = sys.argv[1]
     corrections_file = sys.argv[2]
     output_img_file = sys.argv[3]
     output_text_file = sys.argv[4]
     demo(img_path, corrections_file, output_img_file, output_text_file)

And also a screenchot of the results in Pycharm's Terminal here

Z4-tier
  • 7,287
  • 3
  • 26
  • 42
Acil
  • 3
  • 3

1 Answers1

0

According to this answer, the default install path for Tesseract is C:\Users\USER\AppData\Local\Tesseract-OCR. pytesseract needs the actual tesseract executable, thus you need to set it as pytesseract.pytesseract.tesseract_cmd = r'<wherever tesseract is installed>\tesseract.exe'.

ilke444
  • 2,641
  • 1
  • 17
  • 31