安装tesseract-ocr时出现gcc错误

时间:2016-01-24 22:30:16

标签: python tesseract python-tesseract pytesser

我正在尝试在我的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

我不知道该怎么做。

4 个答案:

答案 0 :(得分:4)

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

sudo apt install libleptonica-dev

答案 1 :(得分:0)

在Linux中,使用以下命令

sudo apt-get install tesseract-ocr

答案 2 :(得分:0)

与yum一起使用:

yum install leptonica-devel tesseract-devel

答案 3 :(得分:0)

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

brew install tesseract

说明

它将安装后端tesseract和相关库leptonica(以及其他库giflib, jpeg, libpng, libtiff, little-cms2, openjpeg, webp),因此可以解决此错误。