赞
踩
Centos7.2
yum install tesseract -y
安装完成后,查看一下目前tesseract所支持的语言:
List of available languages (1):
eng
结果显示只支持英语,如果想要安装多国语言,还需要安装语言包,官方叫做 tessdata ( github链接)
安装命令如下:
git clone https://github.com/tesseract-ocr/tessdata.git
sudo mv tessdata/* /usr/share/tesseract/tessdata
pip3.6 install tesserocr pillow
但是在这一步时却报错了,报错信息如下:
[bi@test3 tessdata]$ pip3.6 install tesserocr pillow Collecting tesserocr Downloading https://files.pythonhosted.org/packages/92/2d/05a7f8387e93c192919b508e4f4936f232bd3d2ca388b9130ae538a9f9ad/tesserocr-2.4.0.tar.gz (56kB) 100% |████████████████████████████████| 61kB 67kB/s Requirement already satisfied: pillow in /home/bi/local/python3.6/lib/python3.6/site-packages Installing collected packages: tesserocr Running setup.py install for tesserocr ... error Complete output from command /home/bi/local/python3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hh4t5zds/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-gokateqg-record/install-record.txt --single-version-externally-managed --compile: pkg-config failed to find tesseract/lept libraries: b"Package tesseract was not found in the pkg-config search path.\nPerhaps you should add the directory containing `tesseract.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'tesseract' found\n" Supporting tesseract v3.04.00 Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 50593792}} running install running build running build_ext building 'tesserocr' extension creating build creating build/temp.linux-x86_64-3.6 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/bi/local/python3.6/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [默认启用] tesserocr.cpp:634:34: 致命错误:leptonica/allheaders.h:没有那个文件或目录 #include "leptonica/allheaders.h" ^ 编译中断。 error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/home/bi/local/python3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hh4t5zds/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-gokateqg-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-hh4t5zds/tesserocr/
当出现这样的错误,需要安装一下 tesseract-devel库
yum install tesseract-devel -y
然后再重新安装 tesserocr
pip3.6 install tesserocr
最后成功安装
[bi@test3 tessdata]$ pip3.6 install tesserocr pillow
Collecting tesserocr
Using cached https://files.pythonhosted.org/packages/92/2d/05a7f8387e93c192919b508e4f4936f232bd3d2ca388b9130ae538a9f9ad/tesserocr-2.4.0.tar.gz
Requirement already satisfied: pillow in /home/bi/local/python3.6/lib/python3.6/site-packages
Installing collected packages: tesserocr
Running setup.py install for tesserocr ... done
Successfully installed tesserocr-2.4.0
参考:https://blog.csdn.net/zyy247796143/article/details/82356867
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。