我试图安装normcap用于OCR读取图像,但遇到了一个错误,不知道如何解决。
PC-Macbook M1芯片组
自制3.1.7安装并运行良好
CommandLinetools 12.5已安装(Apple(
已安装Leptonica 1.80.0
Tesseract 4.1.1已安装
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('"'"'rn'"'"', '"'"'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('"'"'rn'"'"', '"'"'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('"'"'rn'"'"', '"'"'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.
据我所知,我提供了所有需要的信息。如果有什么东西不见了,请告诉我
我是自制软件的新手,但曾在上使用过linux操作系统
还有一种方法我可以从Github或任何存储库直接在自制软件上安装,比如如果在git存储库文件中进行了一些更改,我想直接安装它们,否则需要等待tar.gz或.dmg文件的真实版本
无法从pip安装tesserocr。实际上,正如您在PyPI链接上看到的那样,构建状态被标记为失败。
因此,要安装它,您需要用以下行conda安装它:
conda install -c conda-forge tesserocr
此外,您需要使用Homebrew安装tesseract,如下所示:
brew install tesseract
现在,如果您尝试运行脚本,可能会出现新的错误,表明找不到一些dylib。
为了解决这个新问题,您需要创建符号链接(即符号链接(。在我的情况下,我需要创建这些:
N。B: 在执行以下行之前,请检查/usr/local中是否有一个名为lib的文件夹,如果没有,则创建它
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
通常情况下,现在您可以运行脚本了。
Include地址应为:/opt/homebrew/Cellar/leptonica/1.82.0/include
而不是/opt/homebrew/Cellar/leptonica/1.82.0/include/leptonica
。如果可以将第一个路径添加到path变量中,它可能会起作用。
我在运行C++代码时遇到了同样的问题,我包含了正确的路径,程序找到了leptonics/allheader.h
文件。
很好奇,你找到解决方案了吗?我目前也陷入了这个错误。头文件在/opt/homebrew/Cellar/leptonica/1.82.0/include
中,但运行时会显示缺少头。
第一个brew install tesseract
。然后是CCD_ 6。显然,pip的安装依赖于brew安装。
在pip 23.1.1上,Python 3.10.11。此外,我使用的是一台旧的MacBook,而不是M1,但我遇到了与OP相同的错误。