Search code examples
pythondjangotesseract

No OCR tool found in python


I have downloaded Mayan EDMS-Electronic Document Management System from GitHub and I configured project using Django server. I had added the required libraries based on requirement. Now the project runs with error

ocr.exceptions.OCRError: No OCR tool found

When I searched this error, I found Pyocr looks for the OCR tools (Tesseract, Cuneiform, etc) installed on your system and just tells you what it has found.

Then I tried to install tesseract using the command -->pip install tesseract-ocr.

I got this error

    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"

please help me to solve this issue. Thanks in advance.


Solution

  • Tesseract is installed on the OS using the apt-get command. The command you are using (PIP) is for installing Python packages, that is the reason for the error.

    For reference: http://docs.mayan-edms.com/en/stable/topics/deploying.html#deploying

    If using a Debian or Ubuntu based Linux distribution, get the executable requirements using:

    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