【问题标题】:How To Install Pytesseract in windows 8.1(win64) (visual studio 2012+python+anaconda)如何在 windows 8.1(win64) 中安装 Pytesseract (visual studio 2012+python+anaconda)
【发布时间】:2023-03-13 01:04:01
【问题描述】:
from PIL import Image
from tesseract import image_to_string

print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'))
print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'), lang='eng')

我在安装 tesseract orc 后使用此代码。

Traceback(最近一次调用最后一次): 文件“C:\Users\Uzel\Documents\Visual Studio 2012\Projects\module3.py”,第 28 行,在 从 tesseract 导入 image_to_string ImportError: 无法导入名称 image_to_string

我有这个错误。我试过 pytesseract 但我无法管理。我们能不能解决这个问题。如何?谢谢。

【问题讨论】:

  • C:\Users/Uzel/Desktop/pythonfoto/denklem.png 更改为C:/Users/Uzel/Desktop/pythonfoto/denklem.png
  • 不幸的是不能再工作了。我认为 tesseract 没有 image_to_string。 pytesseract 如果我安装它就不能安装它。
  • 您能详细说明一下吗?您确实对图像路径进行了更改并且它确实工作了一次?
  • 是的,我更改并编译但没有工作。你使用 pytesseract 吗?你能给我建议吗?如何下载?
  • 我正在使用pytesseract。您可能会在下面看到我的答案。

标签: python-2.7 visual-studio-2012 tesseract pytesser


【解决方案1】:

下面是带有pytesseract 的示例代码。

import pytesseract 
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract 4.0.0/tesseract.exe"
print(pytesseract.image_to_string(Image.open("./imagesStackoverflow/text.png"),
                                  lang="eng",boxes=False,config="--psm 3 --eom 3"))

pytesseract.pytesseract.tesseract_cmd是明确指定EXE路径,以防Windows环境下路径设置不正确。

您需要在 Windows 中安装 Tesseract,并在 Python 中安装 pytesseract。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 2013-03-07
    • 1970-01-01
    相关资源
    最近更新 更多