赞
踩
学习Python爬虫首先要配置环境安装tesseract和tesserocr两个库,但是在Mac上按照书中的指导会出现无法解决的安装错误,经过一天时间的试错,总算把这两个库安装完毕可以使用。
tesseract&tesserocr安装指南
1.安装tesseract
终端输入指令brew install tesseract
在安装全语言支持版本的时候,指令为brew install tesseract-lang
验证所支持的语言,指令为tesseract --list-langs
2.安装tesserocr
终端输入指令
采用指令:
pip3 install tesserocr pilow
安装过程及报错:
Collecting tesserocr
Using cached https://files.pythonhosted.org/packages/92/2d/05a7f8387e93c192919b508e4f4936f232bd3d2ca388b9130ae538a9f9ad/tesserocr-2.4.0.tar.gz
Requirement already satisfied: pillow in /anaconda3/lib/python3.7/site-packages (5.3.0)
Building wheels for collected packages: tesserocr
Building wheel for tesserocr (setup.py) ... error
Complete output from command /anaconda3/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/tg/g57hkq3s3g163k6zstsmjfj00000gn/T/pip-install-m92cxqko/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/tg/g57hkq3s3g163k6zstsmjfj00000gn/T/pip-wheel-zpv8cubn --python-tag cp37:
Supporting tesseract v4.0.0
Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 67108864}}
running bdist_wheel
running build
running build_ext
building 'tesserocr' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/anaconda3/include/python3.7m -c tesserocr.cpp -o build/temp.macosx-10.7-x86_64-3.7/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
In file included from tesserocr.cpp:656:
In file included from /usr/local/include/tesseract/genericvector.h:28:
In file included from /usr/local/include/tesseract/tesscallback.h:22:
/usr/local/include/tesseract/host.h:30:10: fatal error: 'cinttypes' file not found
#include <cinttypes> // PRId32, ...
^~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
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
Complete output from command /anaconda3/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/tg/g57hkq3s3g163k6zstsmjfj00000gn/T/pip-install-m92cxqko/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。