P
P
PythonBeginner202018-03-08 23:33:43
Python
PythonBeginner20, 2018-03-08 23:33:43

WinError 2: The specified file cannot be found in pytesseract. How to fix?

OCR=Image.open("F:\MEGA\Проекты\PyCharmProjects\SeoClicker\output.gif")
print(image_to_string(OCR))

Pytesseract throws an error
Traceback (most recent call last):
  File "F:/MEGA/Проекты/PyCharmProjects/SeoClicker/test.py", line 64, in <module>
    print(image_to_string(OCR))
  File "D:\python\lib\site-packages\pytesseract-0.2.0-py3.6.egg\pytesseract\pytesseract.py", line 193, in image_to_string
  File "D:\python\lib\site-packages\pytesseract-0.2.0-py3.6.egg\pytesseract\pytesseract.py", line 140, in run_and_get_output
  File "D:\python\lib\site-packages\pytesseract-0.2.0-py3.6.egg\pytesseract\pytesseract.py", line 111, in run_tesseract
  File "D:\python\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "D:\python\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] Не удается найти указанный файл

The solution to the problem is here: https://www.questarter.com/q/pytesseract-can-39-t-...
import pytesseract
import PIL

''' указываем эти два параметра обязательно! '''
pytesseract.pytesseract.tesseract_cmd = "F:/tess/Tesseract-OCR/tesseract.exe"
tessdata_dir_config = '--tessdata-dir "F:/tess/Tesseract-OCR"'

img = PIL.Image.open("test.png")

# обязательно укажите lang='eng'
text = pytesseract.image_to_string(img, config=tessdata_dir_config, lang="eng")
print(text)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fixid, 2018-03-08
@PythonBeginner20

OCR=Image.open("F:\\MEGA\\Projects\\PyCharmProjects\\SeoClicker\\output.gif")
or use the system independent os.path.join

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question