centos7 yum 安裝 tesseract pip 安裝 python3 tesserocr

centos7 系統 yum 安裝 tesseract,並 pip 安裝 python3 的 tesserocr

2018年09月04日 00:00:27 閱讀數:15 標籤: centos7python3tesserocr 更多python

我的分類: pythonlinux

版權聲明:本文爲博主原創文章,未經博主容許不得轉載。 https://blog.csdn.net/zyy247796143/article/details/82356867git

#安裝epel 源:github

yum -y install epel-release

#安裝tesseract:centos

yum -y install tesseract

#執行檢查tesseract 支持的語言:ui

tesseract --list-langs

List of available languages (1):
eng
 centos7

發現目前只支持英語,要安裝更多語言包可執行git 獲取:spa

 
  1. git clone https://github.com/tesseract-ocr/tessdata.git.net

  2. mv tessdata/* /usr/share/tesseract/tessdatacode

pip 安裝 pillow 和 tesserocr:

pip3 install pillow tesserocr

發現安裝 pillow 成功,tesserocr 報錯了

Installing collected packages: tesserocr

  Running setup.py install for tesserocr ... error

    Complete output from command /usr/local/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-i48iarbe/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-record-p27b42h9/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': 197632}}

    /usr/local/python3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'

      warnings.warn(msg)

    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 -fPIC -I/usr/local/python3/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o

    tesserocr.cpp:597:34: fatal error: leptonica/allheaders.h: No such file or directory

     #include "leptonica/allheaders.h"

                                      ^

    compilation terminated.

    error: command 'gcc' failed with exit status 1

   

    ----------------------------------------

Command "/usr/local/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-i48iarbe/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-record-p27b42h9/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-i48iarbe/tesserocr/

#解決方法,安裝一下 tesseract-devel 庫:

yum install tesseract-devel 

#再從新pip安裝tesserocr:

pip3 install tesserocr

沒報錯,完成!

相關文章
相關標籤/搜索