Reputation: 1
i was trying to install normcap for OCR reading of images but i got into an error and don't understand how to solve it.
PC - Macbook M1 chipset
homebrew 3.1.7 installed and working fine.
CommandLinetools 12.5 have been installed(Apple).
Leptonica 1.80.0 is installed.
Tesseract 4.1.1 installed
asura@Asuras-MBP ~ % pip3 install tesserocr
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Collecting tesserocr
Using cached tesserocr-2.5.1.tar.gz (54 kB)
Building wheels for collected packages: tesserocr
Building wheel for tesserocr (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"'; __file__='"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-wheel-vmhekyq6
cwd: /private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/
Complete output (16 lines):
/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py:72: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if subversion is not None and subversion is not "":
Supporting tesseract v4.1.1
Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 67174656}}
running bdist_wheel
running build
running build_ext
building 'tesserocr' extension
creating build
creating build/temp.macosx-10.14.6-arm64-3.8
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c tesserocr.cpp -o build/temp.macosx-10.14.6-arm64-3.8/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
tesserocr.cpp:663:10: fatal error: 'leptonica/allheaders.h' file not found
#include "leptonica/allheaders.h"
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: 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
ERROR: Command errored out with exit status 1:
command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"'; __file__='"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-record-qagqxk6s/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/asura/Library/Python/3.8/include/python3.8/tesserocr
cwd: /private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/
Complete output (16 lines):
/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py:72: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if subversion is not None and subversion is not "":
Supporting tesseract v4.1.1
Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 67174656}}
running install
running build
running build_ext
building 'tesserocr' extension
creating build
creating build/temp.macosx-10.14.6-arm64-3.8
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c tesserocr.cpp -o build/temp.macosx-10.14.6-arm64-3.8/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
tesserocr.cpp:663:10: fatal error: 'leptonica/allheaders.h' file not found
#include "leptonica/allheaders.h"
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"'; __file__='"'"'/private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-install-44_kap26/tesserocr_10c3c6f9825d4363b69446dbd439cf21/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/w4/n1pwmphn6j13trrwzlzjbpzh0000gn/T/pip-record-qagqxk6s/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/asura/Library/Python/3.8/include/python3.8/tesserocr Check the logs for full command output.
As per my knowledge i provided all the information needed if something is missing please let me know.
i'm new to homebrew but used linux OS's for sometime
and also is there a way i can install from Github or any repository directly on homebrew, like if some changes are made in git repository files i want to install them directly otherwise need to wait for realese of tar.gz or .dmg files
Upvotes: 0
Views: 3270
Reputation: 31
I found a fix here, its for golang but might work for python too. https://github.com/otiai10/gosseract/issues/234
Install with brew install tesseract
export LIBRARY_PATH="/opt/homebrew/lib"
export CPATH="/opt/homebrew/include"
Upvotes: 2
Reputation: 17132
First brew install tesseract
. Then pip install tesserocr
. Apparently the pip install depends on things from the brew install.
On pip 23.1.1, Python 3.10.11. Also I'm on an older MacBook, not an M1, but I got the same error as the OP.
Upvotes: 0
Reputation: 31
It's not possible to install tesserocr from pip. Indeed the build status is noted as failing as you can see on the PyPI link here.
So to install it, you need to conda install it with the following line :
conda install -c conda-forge tesserocr
Moreover you need to install tesseract with Homebrew as following :
brew install tesseract
Now if you try to run your script maybe you will have new error(s) indicating that some dylib are not found.
In order to solve this new problem(s) you need to create symbolic links (i.e. symlinks). In my case I needed to create those ones :
N.B: Before doing the following lines, check if you have a folder named lib in /usr/local, if no then create it
ln -s /opt/homebrew/Cellar/libarchive/3.6.2_1/lib/libarchive.13.dylib /usr/local/lib/libarchive.19.dylib
ln -s /opt/homebrew/Cellar/leptonica/1.82.0_1/lib/liblept.5.dylib /usr/local/lib
ln -s /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.5.dylib /usr/local/lib
ln -s /opt/homebrew/Cellar/libtiff/4.4.0_1/lib/libtiff.5.dylib /usr/local/lib
Normally now you could be able to run your script.
Upvotes: 3
Reputation: 11
Include address should be: /opt/homebrew/Cellar/leptonica/1.82.0/include
instead of /opt/homebrew/Cellar/leptonica/1.82.0/include/leptonica
. If you can add the first path to your PATH variable it might work.
I had the same issue when I was running C++ code, I included the right path and the program found leptonics/allheader.h
file.
Upvotes: 1