当前位置:   article > 正文

Centos中安装tesserocr模块,常见报错及处理方式_no package 'tesseract' found

no package 'tesseract' found
系统环境

Centos7.2

安装tesseract:
yum install  tesseract -y
  • 1

安装完成后,查看一下目前tesseract所支持的语言:

List of available languages (1):
eng
  • 1
  • 2

结果显示只支持英语,如果想要安装多国语言,还需要安装语言包,官方叫做 tessdata ( github链接

安装命令如下:

git clone https://github.com/tesseract-ocr/tessdata.git
sudo mv tessdata/* /usr/share/tesseract/tessdata
  • 1
  • 2
安装 tesserocr:
pip3.6 install tesserocr pillow
  • 1

但是在这一步时却报错了,报错信息如下:

[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/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

当出现这样的错误,需要安装一下 tesseract-devel库

yum install tesseract-devel -y
  • 1

然后再重新安装 tesserocr

pip3.6 install tesserocr
  • 1

最后成功安装

[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

 

参考:https://blog.csdn.net/zyy247796143/article/details/82356867

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/119811
推荐阅读
相关标签
  

闽ICP备14008679号