sirfz / tesserocr

A Python wrapper for the tesseract-ocr API
MIT License
2.02k stars 254 forks source link

pip install tesserocr error #172

Closed vinsec closed 5 years ago

vinsec commented 5 years ago

Environment: CentOS 7 Linux 3.10.0-957.1.3.el7.x86_64

Software Version: Python 3.7.2 tesseract 3.04.00 leptonica-1.72 libgif 4.1.6(?) : libjpeg 6b (libjpeg-turbo 1.2.90) : libpng 1.5.13 : libtiff 4.0.3 : zlib 1.2.7 : libwebp 0.3.0

Problem: After installing tesseract 3.04 successfully,I tried using pip to install tesserocr but failed. These are the error messages:

[root@node ~]# pip install tesserocr
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting tesserocr
  Downloading http://mirrors.tencentyun.com/pypi/packages/92/2d/05a7f8387e93c192919b508e4f4936f232bd3d2ca388b9130ae538a9f9ad/tesserocr-2.4.0.tar.gz (56kB)
    100% |████████████████████████████████| 61kB 6.7MB/s 
Installing collected packages: tesserocr
  Running setup.py install for tesserocr ... error
    Complete output from command /usr/local/python3/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dgd7506m/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-tk5ths61/install-record.txt --single-version-externally-managed --compile:
    /tmp/pip-install-dgd7506m/tesserocr/setup.py:152: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
      _LOGGER.warn('pkg-config failed to find tesseract/lept libraries: {}'.format(e))
    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.7
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/python3/include/python3.7m -c tesserocr.cpp -o build/temp.linux-x86_64-3.7/tesserocr.o
    tesserocr.cpp:629: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.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dgd7506m/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-tk5ths61/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-dgd7506m/tesserocr/

It seems that there is something wrong with leptonica. By the way,tesseract and leptonica are installed automatically bu YUM.

vinsec commented 5 years ago

tesseract-devel should be installed before :

yum -y install tesseract-devel