tesseract / tesserocr / leptonica packages fails in Python application while deploying on Bluemix - python

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

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:
https://docs.cloudfoundry.org/buildpacks/
https://docs.cloudfoundry.org/buildpacks/developing-buildpacks.html

Related

Installing `dulwich` gives `error: command 'clang' failed with exit status 1`

When I try to execute pip install dulwich, I end up with a wall of red complaining about clang. Here's the last bit:
Please check your Xcode installation
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/opt/openssl#1.1/include -I/usr/local/opt/sqlite/include -I/Users/alaird/Developer/py3venv/include -I/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c dulwich/_objects.c -o build/temp.macosx-10.14-x86_64-3.7/dulwich/_objects.o
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from dulwich/_objects.c:20:
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command "/Users/alaird/Developer/py3venv/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/63/r_rf7mhj14b4c42mfkkl06t8rg1b1r/T/pip-install-b9wlh7xh/dulwich/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/63/r_rf7mhj14b4c42mfkkl06t8rg1b1r/T/pip-record-_v0dq_sp/install-record.txt --single-version-externally-managed --compile --install-headers /Users/alaird/Developer/py3venv/include/site/python3.7/dulwich" failed with error code 1 in /private/var/folders/63/r_rf7mhj14b4c42mfkkl06t8rg1b1r/T/pip-install-b9wlh7xh/dulwich/
I've gone down a lot of "clang failed with exit status 1" rabbit holes on Google, problem is that's too generic. To answer a few questions:
Yes, Xcode is the latest version, and command-line tools have been installed (I'm on OS X 10.14.6, so this is now managed through app updates).
This was a previously working installation. This error began occuring after I did a make clean, which blew away my venv.
Attempting to install the latest setuptools runs in to the same error, so feels like the error pointing to Xcode/my build environment (and not dulwich) is the correct culprit.
Doing a brew update also gives me the same clang barf. I think something got hosed when I upgraded to Mojave.
Ideas?
Ah-ha!
I started looking at the warning instead of the error:
no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
And this led me to notice a SDK version number was hardcoded ... which seems stupid. So I built a symlink:
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Depending on your system configuration, you may need to build a different symlink (there was also a MacOSX10.15.sdk folder).
Then it worked! No issues with pip (including installing dulwich and pycrypto), no issues with brew, and all is well with my development environment again!
I also did:
export CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
However, I don't believe that was what did it, since after starting a new session all still worked. So it was probably the symlink above that resolved it. Hope this helps others!

pip install module error

hello guys i tried to install a python module called gmpy2 with pip install gmpy2 but error occurs during wheel building
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-
prototypes -g -fdebug-prefix-map=/build/python3.6-LpWKty/python3.6-
3.6.5~rc1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-
protector-strong -Wformat -Werror=format-security -Wdate-time -
D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -
I/usr/include/python3.6m -c src/gmpy2.c -o build/temp.linux-x86_64-
3.6/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
# include "mpfr.h"
^~~~~~~~
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-
onv0x975/gmpy2/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-izolloyr-record/install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in /tmp/pip-
build-onv0x975/gmpy2/
I tried both pip and pip3
You need to download MPFR source code and compile it. See installation manual: https://gmpy2.readthedocs.io/en/latest/intro.html#installation

Can't install module python pip

i'm new to python. I'd like to use pysnmp module, so i tried to install it with pip but i'm getting errors from it :
Failed building wheel for pycrypto
I tried on multiple system (Ubuntu, Debian and RH) and I always get the same error. How can i install pysnmp ? Or are there any other alternative to work with snmp with python ?
Shell Command :
sudo -H pip install pysnmp
Result :
...
configure: creating ./config.status
config.status: creating src/config.h
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastm ath.
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/src
x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -Wstrict-prototypes -fstack-prot ector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOUR CE=2 -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.4m -c src/MD2.c -o build/temp.linux-x86_64-3.4/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
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-7gwchpkq/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(_ _file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp /pip-6mlabkyq-record/install-record.txt --single-version-externally-managed --co mpile" failed with error code 1 in /tmp/pip-build-7gwchpkq/pycrypto/
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
The actual error is that you do not have the dev files for python language (python.h not found).
So, install python-dev:
sudo apt-get install python-dev
Try:
sudo pip install setuptools --upgrade
Try,
wget https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py
easy_install pysnmp

How to install python cairo?

I am new to python3. I have created the virtual environment. I try to install the pycairo package using pip command. I need install python cairo. Please see the below info
pip install git+http://anongit.freedesktop.org/git/pycairo
Downloading/unpacking git+http://anongit.freedesktop.org/git/pycairo
Cloning http://anongit.freedesktop.org/git/pycairo to /tmp/pip-0c_foz-build
Running setup.py egg_info for package from git+http://anongit.freedesktop.org/git/pycairo
cairo >= 1.10.2 Successful
Installing collected packages: pycairo
Running setup.py install for pycairo
cairo >= 1.10.2 Successful
building 'cairo._cairo' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o
src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2:
cairo >= 1.10.2 Successful
creating py3cairo.pc
creating src/config.h
running install
running build
running build_ext
building 'cairo._cairo' extension
creating build
creating build/temp.linux-i686-3.2
creating build/temp.linux-i686-3.2/src
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o
src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2 failed with error code 1 in /tmp/pip-0c_foz-build
Storing complete log in /home/nyros/.pip/pip.log
But I got the error. Please solve my problem. Thanks
I think this may solve your problem:
sudo apt-get install python3-dev
But I cannot guarantee that this will work 100% :-)

'gcc-4.2' failed with exit status 1 when installing bcrypt

Hi all im new to django and python trying to install bcrypt which is needed for building a piece of django code im trying to run on my system, im running into a problem as below
im using python 2.7 and v1.4 django
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c bcrypt/bcrypt_python.c -o build/temp.macosx-10.6-intel-2.7/bcrypt/bcrypt_python.o
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
from bcrypt/bcrypt_python.c:17:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
from bcrypt/bcrypt_python.c:17:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/2s/n9wb5x4534nfs1cbrlph32v00000gp/T//ccb7N3qq.out
error: command 'gcc-4.2' failed with exit status 1
----------------------------------------
Command /Users/Kinnovate/Downloads/dwaiter-django-bcrypt-913d86b/my_new_env/bin/python -c "import setuptools;__file__='/Users/Kinnovate/Downloads/dwaiter-django-bcrypt-913d86b/my_new_env/build/py-bcrypt/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/2s/n9wb5x4534nfs1cbrlph32v00000gp/T/pip-yONWs2-record/install-record.txt --install-headers /Users/Kinnovate/Downloads/dwaiter-django-bcrypt-913d86b/my_new_env/bin/../include/site/python2.7 failed with error code 1
how do i fix this?
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
I believe stdarg.h. is part of the standard C library, libstdc (or possibly the standard C++ library libstdc++.) This smells to me like libstdc is missing or not located where the compiler thinks it is.
Googling your error message (stdarg.h: No such file or directory) produces a stack of hits on StackOverflow and elsewhere. See here or here for what appear to be exact solutions to your problem.

Categories