【发布时间】:2018-10-29 07:26:34
【问题描述】:
我正在尝试为我们学校的网站制作一个自动登录程序,该程序需要识别验证码中的文本。于是我从 pip 安装了pytesseract,并在 PyCharm 中运行程序:(图像在目录 /Users/macintosh/Documents/PythonOutputs/2.jpg)
import pytesseract
from PIL import Image
image = Image.open("/Users/macintosh/Documents/PythonOutputs/2.jpg")
text = pytesseract.image_to_string(image)
print(text)
但是发生了这个错误:
Traceback(最近一次调用最后一次):文件 "/Users/macintosh/Library/Preferences/PyCharmCE2018.2/scratches/scratch_3.py", 第 5 行,在 text = pytesseract.image_to_string(image)
文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 294 行,在 image_to_string 中 return run_and_get_output(*args)
文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 202 行,在 run_and_get_output 中 run_tesseract(**kwargs)
文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 178 行,在 run_tesseract raise TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (2, '用法:python pytesseract.py [-l lang] input_file')
有什么问题?
【问题讨论】: