如何在 windows 上安装 tesserocr?

How to install tesserocr on windows?

我下载了tesseract-OCR的可执行文件并安装了它。另一方面,我还从 http://www.leptonica.com/download.html 下载了 leptonica 的 zip 文件。它包括两个目录,即libinclude

接下来我尝试在 python 虚拟环境中执行 pip install tesserocr,但它返回了错误

 tesserocr.cpp(460) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory

我注意到 allheaders.h 位于我之前下载的 leptonica 文件的 include 目录中。我该如何解决这个问题?我应该把我从 leptonica 获得的目录 includelib 放在哪里才能完成这项工作?

有没有其他方法可以在 windows 计算机上安装 tesseract-ocr 并正确使用 tesserocr?目前我正在使用 Windows 10 到 运行 我的 python 脚本,该脚本使用 tesseract-ocr 来识别图像上的某些字符。我还打算稍后 运行 windows 7 台计算机上的脚本。

感谢您的帮助。

基本上,要在 windows 上安装任何软件包,请转到 LIBS 位置并 运行 命令

 "py -3.4 -m pip install SomePackage"

对于 tesseract 要么按照这里:http://emop.tamu.edu/Installing-Tesseract-Windows8

从此处下载设置 (https://pypi.python.org/pypi/pytesseract) 并双击设置。 希望对你有帮助。

使用 Anaconda 在名为 OCR

的环境中安装 TesserOCR
  1. here
  2. 为 Windows 安装 Anaconda
  3. 打开 Anaconda 提示符:

    conda create -n OCR python=3.6

    activate OCR

  4. 对于 tesseract 3.5.1(稳定):

    conda install -c simonflueckiger tesserocr

    OR 对于 tesseract 4.0.0(实验):

    conda install -c simonflueckiger/label/tesseract-4.0.0-master tesserocr

    here下载与您的Windows平台和Python安装相匹配的wheel文件并通过以下方式安装:

    pip install <path_to_your_wheel_file>

这个方法非常适合我: 使用Anaconda在名为OCR

的环境中安装TesserOCR
Install Anaconda for Windows from here

Open Anaconda Prompt:

conda create -n OCR python=2.7

activate OCR

You should install Anaconda and tesserac

https://www.anaconda.com/distribution/#download-section 并在提示命令 write

conda install -c simonflueckiger tesserocr

conda install -c simonflueckiger/label/tesseract-4.0.0-master tesserocr

我知道这对你来说为时已晚,但它可能会对其他人有所帮助。

为了消除安装 tesseract-ocr 时的错误,leptonica 的安装根本不是一个完整的解决方案。使用 windows 安装程序可用 here 安装 tesseract 后,您应该将 python 包装器安装为:

pip install pytesseract

最后但同样重要的是,您还应该在导入 pytesseract 库后在脚本中设置 tesseract 路径,如下所示(请不要忘记安装路径可能会根据您的情况进行修改!):

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'