0

I am trying to deploy a Python application for Image recognition which uses tesseract, tesserocr with leptonica. But I get the following error while deploying it on Bluemix.

Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-0jQxGj/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-yIT1DQ-record/install-record.txt --single-version-externally-managed --compile:
       pkg-config failed to find tesseract/lept libraries: Package tesseract was not found in the pkg-config search path.
       Perhaps you should add the directory containing `tesseract.pc'
       No package 'tesseract' found

       to the PKG_CONFIG_PATH environment variable
       Failed to extract tesseract version from executable: [Errno 2] No such file or directory
       Supporting tesseract v3.04.00
       Building with configs: {'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-2.7
       gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c tesserocr.cpp -o build/temp.linux-x86_64-2.7/tesserocr.o
       cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
       tesserocr.cpp:555: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
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • Can you please share your requirements.txt, manifest.yml and the command you use to push your app to cloud foundry? – Chris Snow Oct 31 '17 at 08:32
  • requirements.txt: ----------------------- Flask numpy Pillow==4.1.1 pycosat pycparser pyOpenSSL pyparsing pytesseract python-dateutil python-swiftclient pytz PyWavelets scikit-image scipy requests matplotlib==1.4.3 opencv-python cf_deployment_tracker tesseract tesserocr manifest.yml: ------------------ applications: - path: . memory: 512M instances: 1 domain: mybluemix.net name: edge-noise-detector-bluemix host: edge-noise-detector-bluemix disk_quota: 1024M – Pankaj Dubey Oct 31 '17 at 15:48

1 Answers1

1

It looks as though the build pack you are using does not have the required libraries to compile tesseract.

You could try a different buildpack such as python-tesseract-buildpack. Note that this buildpack is quite out of date with the python-buildpack from which it was originally forked (407 commits behind cloudfoundry:master).

If the above buildpack works for you, you may want to create your own custom buildpack based on the latest python buildpack and the changes made to it by the python-tesseract-buildpack. There is more information on buildpacks here:

Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • The issue is the code is not able to detect the path of tesseract. I faced the same issue in eclipse with PyDev and got it resolved by hardcoding the path in my server.py class where I imported pytesseract like this: pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract' The same does not work on bluemix, even when I copied the tesseract file and deployed along with the project. – Pankaj Dubey Nov 09 '17 at 04:41