安装tesseract-ocr时出现gcc错误

Jas*_*lam 3 python tesseract python-tesseract pytesser

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

import Image
enter code here`import pytesseract
im = Image.open('test.png')
print pytesseract.image_to_string(im)
Run Code Online (Sandbox Code Playgroud)

从这里提出以下问题:pytesseract-没有此类文件或目录错误, 我需要安装tesseract-ocr

但是,当我尝试点安装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
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么办。

小智 5

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

sudo apt install libleptonica-dev
Run Code Online (Sandbox Code Playgroud)