【问题标题】:gcc error on install of tesseract-ocr安装 tesseract-ocr 时出现 gcc 错误
【发布时间】:2016-05-01 03:44:41
【问题描述】:

我正在尝试在我的 Mac 上运行以下代码。

import Image
enter code here`import pytesseract
im = Image.open('test.png')
print pytesseract.image_to_string(im)

从这里提问:pytesseract-no such file or directory error 我需要安装 tesseract-ocr

但是当我尝试 pip install tesseract-ocr 时出现以下错误:

creating build/temp.macosx-10.5-x86_64-2.7
gcc -fno-strict-aliasing -I//anaconda/include -arch x86_64 -DNDEBUG -g
-fwrapv -O3 -Wall -Wstrict-prototypes -I//anaconda/include/python2.7 -c
tesseract_ocr.cpp -o build/temp.macosx-10.5-x86_64-2.7/tesseract_ocr.o
tesseract_ocr.cpp:264:10: 
fatal error: 'leptonica/allheaders.h' file not found #include "leptonica/allheaders.h"
     ^
1 error generated.
error: command 'gcc' failed with exit status 1

我不知道该怎么办。

【问题讨论】:

  • 你需要安装一个 C 库,这里应该可以使用 leptonica.org/download.html ;如果您使用的是 brew,brew install leptonica 可能会有所帮助。
  • 我试过pip install leptonica但收到另一个错误Could not find a version that satisfies the requirement leptonica (from versions: ) No matching distribution found for leptonica
  • 如果pip install leptonica 是可能的,pip install tesseract-ocr 会自动执行。

标签: python tesseract python-tesseract pytesser


【解决方案1】:

您需要在系统中安装libleptonica-devtesseract-ocr-dev

sudo apt install libleptonica-dev
sudo apt install tesseract-ocr-dev

【讨论】:

  • 非常感谢!!!工作。
【解决方案2】:

与 yum 一起使用:

yum install leptonica-devel tesseract-devel

【讨论】:

    【解决方案3】:

    在 Linux 中使用以下命令

    sudo apt-get install tesseract-ocr
    

    【讨论】:

      【解决方案4】:

      参考another post,我的 Mac 上的最终解决方案

      brew install tesseract

      解释

      它将安装后端tesseract 和依赖库leptonica(和其他库:giflib, jpeg, libpng, libtiff, little-cms2, openjpeg, webp),因此可以修复此错误。

      【讨论】:

        猜你喜欢
        • 2018-11-26
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-11
        • 2016-06-05
        • 2014-07-10
        • 1970-01-01
        相关资源
        最近更新 更多