我正在运行Python2.6.6,希望安装pytesseract包。在提取和安装之后,我可以从命令行调用pytesseract。不过,我想在python中运行tesseract。我有以下代码(ocr.py):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'))
当我使用python ocr.py运行代码时,得到以下输出:Traceback (most recent call last):
File "ocr.py", line 6, in
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和test-european.jpg位于工作目录中。有人能帮我运行这个代码吗?
我试过以下方法:将tesseract命令调整为“pytesseract”
已安装tesseract ocr
任何帮助都是感激的,因为我正在努力解决这个问题几个小时了。