首页 > 解决方案 > 在 python 中找不到 OCR 工具

问题描述

我从 GitHub 下载了 Mayan EDMS-电子文档管理系统,并使用 Django 服务器配置了项目。我已经根据要求添加了所需的库。现在项目运行出错

ocr.exceptions.OCRError: No OCR tool found

当我搜索此错误时,我发现 Pyocr 会查找安装在您系统上的 OCR 工具(Tesseract、Cuneiform 等)并告诉您它找到了什么。

然后我尝试使用命令 -->pip install tesseract-ocr 安装 tesseract。

我收到了这个错误

    Requirement already satisfied: cython in ./venv2/lib/python2.7/site-packages (from tesseract-ocr) (0.28.4)
running bdist_wheel
  running build
  running build_py
  file tesseract_ocr.py (for module tesseract_ocr) not found
  file tesseract_ocr.py (for module tesseract_ocr) not found
  running build_ext
  building 'tesseract_ocr' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-l1RrwO/python2.7-2.7.14=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c tesseract_ocr.cpp -o build/temp.linux-x86_64-2.7/tesseract_ocr.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  tesseract_ocr.cpp:600:10: fatal error: leptonica/allheaders.h: No such file or directory
   #include "leptonica/allheaders.h"

请帮我解决这个问题。提前致谢。

标签: pythondjangotesseract

解决方案


Tesseract 使用 apt-get 命令安装在操作系统上。您使用的命令(PIP)用于安装 Python 包,这就是错误的原因。

供参考:http ://docs.mayan-edms.com/en/stable/topics/deploying.html#deploying

如果使用基于 Debian 或 Ubuntu 的 Linux 发行版,请使用以下命令获取可执行要求:

sudo apt-get install g++ gcc ghostscript gnupg1 graphviz libjpeg-dev libmagic1 \
libpq-dev libpng-dev libreoffice libtiff-dev poppler-utils postgresql \
python-dev python-pip python-virtualenv redis-server sane-utils supervisor \
tesseract-ocr zlib1g-dev -y

推荐阅读