今天在 Mac 上安装Tesserocr 稀里糊涂报一堆错误,接下来就说说遇到的各种问题
首先使用 Homebrew 安装 Imagemagick 和 Tesseract 库
brew install imagemagick
brew install tesseract --all-languages
在进行第二条命令的时候出现以下错误:
接着 Google 一番发现,看到了如下命令
brew install --with-all-languages tesseract
还是报错
于是放弃使用参数,直接安装
brew install tesseract
接着安装 Tesserocr
pip3 install tesserocr pillow
验证安装 编写一个 Python 文件写入如下内容
import tesserocr
from PIL import Image
image = Image.open('image.png')
print(tesserocr.image_to_text(image))
然后运行程序又报错......
接着 搜索引擎又翻了下找到如下方式:
export LC_ALL=C
然而并没什么卵用,最后在文件中加入如下语句才成功
import locale
locale.setlocale(locale.LC_ALL, 'C')
import tesserocr
from PIL import Image
image = Image.open('image.png')
print(tesserocr.image_to_text(image))
总的来说过程还是很曲折的
参考链接:
https://germey.gitbooks.io/python3webspider/content/1.3.4-Tesserocr%E7%9A%84%E5%AE%89%E8%A3%85.html