使用pytesseract出现错误:“[WinError 2] 系统找不到指定的文件。”

环境:

windows 10 x64
python 3.5.2
Pillow-3.4.2
tesseract-ocr 4.0
pytesseract 0.1.6

代码是这样的:

# -*- coding: utf-8 -*-

import pytesseract
from PIL import Image

image = Image.open('d:/testimages/name.gif')

vcode = pytesseract.image_to_string(image)

print(vcode)

上面代码执行的时候出现如下错误:

C:\Users\dell\AppData\Local\Programs\Python\Python35\python.exe D:/scrapyspider/single/test.py
Traceback (most recent call last):
  File "D:/scrapyspider/single/test.py", line 9, in <module>
    vcode = pytesseract.image_to_string(image)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
    config=config)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
    stderr=subprocess.PIPE)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
阅读 14.7k
1 个回答

import pytesseract

pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-ORC/tesseract'