我已经用自制软件安装了 Tesseract,并且在命令行上它工作正常,例如:
tesseract "image.jpg" output.txt
但是当我尝试将它与 python tesseract 包装器(如 textract 或 pytesseract)结合使用时,我收到此错误:
textract.exceptions.ShellError: The command `tesseract "captcha.jpg"
/var/folders/1k/30brhf2n2y7ct_z7rhgtm9qr0000gn/T/tmpcFy9Sk >
/dev/null && cat /var/folders/1k/30brhf2n2y7ct_z7rhgtm9qr0000gn/T/tmpcFy9Sk.txt &&
rm -f /var/folders/1k/30brhf2n2y7ct_z7rhgtm9qr0000gn/T/tmpcFy9Sk /var/folders/1k/30brhf2n2y7ct_z7rhgtm9qr0000gn/T/tmpcFy9Sk.txt`
failed because the executable
`tesseract` is not installed on your system. Please make
sure the appropriate dependencies are installed before using textract
当我尝试时:
from subprocess import call
call(["tesseract", "image.jpg", "output.txt"])
我得到错误:
OSError: [Errno 2] No such file or directory
brew info tesseract 返回:
tesseract: stable 3.04.01 (bottled), HEAD
OCR (Optical Character Recognition) engine
https://github.com/tesseract-ocr/
/usr/local/Cellar/tesseract/3.04.01_1 (76 files, 38.8M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew- core/blob/master/Formula/tesseract.rb
==> Dependencies
Required: leptonica ✔
Recommended: libtiff ✔