Mac 下安装 Tesserocr
今天在 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
https://gist.github.com/henrik/1967035
关于极客返利
极客返利 是由我个人开发的一款网课返利、返现平台。包含 极客时间返现、拉勾教育返现、掘金小册返现、GitChat返现。目前仅包含这几个平台。后续如果有需要可以考虑其他平台。 简而言之就是:你买课,我返现。让你花更少的钱,就可以买到课程。
版权许可
本作品采用 知识共享署名 4.0 国际许可协议 进行许可。转载无需与我联系,但须注明出处,注明文章来源 Mac 下安装 Tesserocr