sirfz / tesserocr

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

unable to install tesserocr (missing tesseract/osdetect.h) #133

Closed bharathgs closed 6 years ago

bharathgs commented 6 years ago

Tesseract details:

`tesseract --version
tesseract 4.0.0-beta.3-204-gf47da
leptonica-1.76.0
  libjpeg 8d (libjpeg-turbo 1.5.2) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11
 Found AVX2
 Found AVX

` OS details: ubuntu 18.04

stack trace:

when i try to install tesserocr I end up with this error, any help on how to fix this would be really helpful

Collecting tesserocr
  Using cached https://files.pythonhosted.org/packages/49/fc/f5d3ca8606566073919a5964118591734e91ee8e42adcc0cc8fcefc3953a/tesserocr-2.3.0.tar.gz
Building wheels for collected packages: tesserocr
  Running setup.py bdist_wheel for tesserocr ... error
  Complete output from command /home/xenomorph/applications/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rlhen_6j/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-nrllmf2_ --python-tag cp36:
  Supporting tesseract v4.0.0-beta.3-204-gf47da
  Configs from pkg-config: {'include_dirs': ['/usr/local/include'], 'library_dirs': ['/usr/local/lib'], 'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}}
  running bdist_wheel
  running build
  running build_ext
  building 'tesserocr' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -B /home/xenomorph/applications/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/home/xenomorph/applications/anaconda3/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  tesserocr.cpp:496:10: fatal error: tesseract/osdetect.h: No such file or directory
   #include "tesseract/osdetect.h"
            ^~~~~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for tesserocr
  Running setup.py clean for tesserocr
Failed to build tesserocr

Installing collected packages: tesserocr
  Running setup.py install for tesserocr ... error
    Complete output from command /home/xenomorph/applications/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rlhen_6j/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-nbpzp6hw/install-record.txt --single-version-externally-managed --compile:
    Supporting tesseract v4.0.0-beta.3-204-gf47da
    Configs from pkg-config: {'include_dirs': ['/usr/local/include'], 'library_dirs': ['/usr/local/lib'], 'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}}
    running install
    running build
    running build_ext
    building 'tesserocr' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -B /home/xenomorph/applications/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/home/xenomorph/applications/anaconda3/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    tesserocr.cpp:496:10: fatal error: tesseract/osdetect.h: No such file or directory
     #include "tesseract/osdetect.h"
              ^~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/xenomorph/applications/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rlhen_6j/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-nbpzp6hw/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-rlhen_6j/tesserocr/
zajacm commented 6 years ago

The same with beta.1

tesseract 4.0.0-beta.1-262-g555f
 leptonica-1.76.0
  libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.4 : libopenjp2 2.3.0
 Found AVX
 Found SSE
pip3 install tesserocr
Collecting tesserocr
  Using cached https://files.pythonhosted.org/packages/49/fc/f5d3ca8606566073919a5964118591734e91ee8e42adcc0cc8fcefc3953a/tesserocr-2.3.0.tar.gz
Building wheels for collected packages: tesserocr
  Running setup.py bdist_wheel for tesserocr ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-c3ey3evp/tesserocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpv0r00fadpip-wheel- --python-tag cp35:
  Failed to extract tesseract version number from: tesseract: symbol lookup error: tesseract: undefined symbol: _Z16tprintf_internalPKcz
  Supporting tesseract v3.04.00
  Building with configs: {'cython_compile_time_env': {'TESSERACT_VERSION': 197632}, 'libraries': ['tesseract', 'lept']}
  build parameters: {'cython_compile_time_env': {'TESSERACT_VERSION': 197632}, 'libraries': ['tesseract', 'lept']}
  running bdist_wheel
  running build
  running build_ext
  building 'tesserocr' extension
  creating build
  creating build/temp.linux-x86_64-3.5
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c tesserocr.cpp -o build/temp.linux-x86_64-3.5/tesserocr.o
  cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
  In file included from /usr/include/c++/5/cinttypes:35:0,
                   from /usr/include/tesseract/host.h:30,
                   from /usr/include/tesseract/tesscallback.h:22,
                   from /usr/include/tesseract/genericvector.h:28,
                   from tesserocr.cpp:600:
  /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   #error This file requires compiler and library support \
    ^
  tesserocr.cpp:611:32: fatal error: tesseract/osdetect.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for tesserocr
  Running setup.py clean for tesserocr
Failed to build tesserocr
Installing collected packages: tesserocr
  Running setup.py install for tesserocr ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-c3ey3evp/tesserocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-psyxr2lt-record/install-record.txt --single-version-externally-managed --compile:
    Failed to extract tesseract version number from: tesseract: symbol lookup error: tesseract: undefined symbol: _Z16tprintf_internalPKcz
    Supporting tesseract v3.04.00
    Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 197632}}
    build parameters: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 197632}}
    running install
    running build
    running build_ext
    building 'tesserocr' extension
    creating build
    creating build/temp.linux-x86_64-3.5
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c tesserocr.cpp -o build/temp.linux-x86_64-3.5/tesserocr.o
    cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
    In file included from /usr/include/c++/5/cinttypes:35:0,
                     from /usr/include/tesseract/host.h:30,
                     from /usr/include/tesseract/tesscallback.h:22,
                     from /usr/include/tesseract/genericvector.h:28,
                     from tesserocr.cpp:600:
    /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support \
      ^
    tesserocr.cpp:611:32: fatal error: tesseract/osdetect.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-c3ey3evp/tesserocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-psyxr2lt-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-c3ey3evp/tesserocr/
sirfz commented 6 years ago

duplicate of #129

ojnc commented 5 years ago

Try this command ldd /usr/bin/tesseract Output should look like linux-vdso.so.1 (0x00007ffe30f46000) libtesseract.so.4 => /usr/lib/x86_64-linux-gnu/libtesseract.so.4 (0x00007fe2e81bd000) liblept.so.5 => /usr/lib/x86_64-linux-gnu/liblept.so.5 (0x00007fe2e7d5b000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe2e79d2000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe2e77ba000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe2e73c9000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe2e71aa000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe2e6e0c000) libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fe2e6bdd000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe2e69c0000) libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fe2e678e000) libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fe2e6526000) libgif.so.7 => /usr/lib/x86_64-linux-gnu/libgif.so.7 (0x00007fe2e631d000) libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007fe2e60a6000) libwebp.so.6 => /usr/lib/x86_64-linux-gnu/libwebp.so.6 (0x00007fe2e5e3d000) libopenjp2.so.7 => /usr/lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007fe2e5be5000) /lib64/ld-linux-x86-64.so.2 (0x00007fe2e8b7a000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe2e59e1000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fe2e57bb000) libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007fe2e55ad000)

The libraries must be physically present In my case I had compiled from source and 2 libraries were in /usr/local/lib libtesseract liblept

I deinstalled deleted the tess and lept from /usr/local/lib When I reinstalled the 2 libraries went to /usr/lib and tesseract worked fine!