我正在运行python 2.6.6并且想要安装pytesseract包。解压缩和安装后,我可以从命令行调用pytesseract。但是我想在Python中运行tesseract。我有以下代码(ocr.py):在pytesseract运行示例代码
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('test.png')))
print(pytesseract.image_to_string(Image.open('test-european.jpg'),lang='fra'))
当我运行由蟒蛇ocr.py的代码,我得到以下输出:
Traceback (most recent call last):
File "ocr.py", line 6, in <module>
print(pytesseract.image_to_string(Image.open('test.png')))
File "/pytesseract-0.1.6/build/lib/pytesseract/pytesseract.py", line 164, in image_to_string
raise TesseractError(status, errors)
pytesseract.TesseractError: (2, 'Usage: python tesseract.py [-l language] input_file')
test.png和测试的欧洲。 jpg在工作目录中。有人可以帮我运行这段代码吗? 我曾尝试以下:
- 调整了tesseract_cmd为“pytesseract”
- 安装的Tesseract-OCR
因为我想现在就解决这个问题了几个小时的任何帮助表示赞赏。
'tesseract test.png stdout'工作吗? – wrwrwr