Centos中安装tesserocr模块,常见报错及处理方式

系统环境

Centos7.2

安装tesseract:
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
安装 tesserocr:
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值