sirfz / tesserocr

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

Failure to build with python:3.11-buster #319

Closed Lenny4 closed 1 year ago

Lenny4 commented 1 year ago

Here is my Dockerfile:

FROM python:3.11-buster AS app

WORKDIR /srv/app

ENV PYTHONPATH /srv/app

RUN apt update -y && \
    apt install -y libegl1 libgl1 libxkbcommon-x11-0 dbus tesseract-ocr liblept5 leptonica-progs libleptonica-dev libtesseract-dev
RUN pip install --upgrade pip

When I connect to my container and I launch: pip install tesserocr

I got error:

$ pip install tesserocr
Collecting tesserocr
  Downloading tesserocr-2.6.0.tar.gz (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.6/58.6 kB 929.0 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: tesserocr
  Building wheel for tesserocr (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [32 lines of output]
      Supporting tesseract v4.0.0
      Tesseract major version 4
      Configs from pkg-config: {'library_dirs': [], 'include_dirs': ['/usr/include', '/usr/include'], 'libraries': ['tesseract', 'lept'], 'compile_time_env': {'TESSERACT_MAJOR_VERSION': 4, 'TESSERACT_VERSION': 67108864}}
      /usr/local/lib/python3.11/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      running bdist_wheel
      running build
      running build_ext
      Detected compiler: unix
      building 'tesserocr' extension
      creating build
      creating build/temp.linux-x86_64-cpython-311
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/include -I/usr/local/include/python3.11 -c tesserocr.cpp -o build/temp.linux-x86_64-cpython-311/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
      tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
      tesserocr.cpp:22546:14: error: ‘TessAltoRenderer’ is not a member of ‘tesseract’
         tesseract::TessAltoRenderer *__pyx_t_6;
                    ^~~~~~~~~~~~~~~~
      tesserocr.cpp:22546:14: note: suggested alternative: ‘TessOsdRenderer’
         tesseract::TessAltoRenderer *__pyx_t_6;
                    ^~~~~~~~~~~~~~~~
                    TessOsdRenderer
      tesserocr.cpp:22546:32: error: ‘__pyx_t_6’ was not declared in this scope
         tesseract::TessAltoRenderer *__pyx_t_6;
                                      ^~~~~~~~~
      tesserocr.cpp:22546:32: note: suggested alternative: ‘__pyx_t_5’
         tesseract::TessAltoRenderer *__pyx_t_6;
                                      ^~~~~~~~~
                                      __pyx_t_5
      tesserocr.cpp:22645:23: error: expected type-specifier
             __pyx_t_6 = new tesseract::TessAltoRenderer(__pyx_v_outputbase);
                             ^~~~~~~~~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tesserocr
  Running setup.py clean for tesserocr
Failed to build tesserocr
ERROR: Could not build wheels for tesserocr, which is required to install pyproject.toml-based projects
zdenop commented 1 year ago

Tesseract 4 is old and unsupported version. Did you tried to use current tesseract version (5.3)?

zdenop commented 1 year ago

I am not sure why you closed this issue "as not planned", but there are Windows version of tesserocr for Python 3.6-3.11, so it is already done.