gpt4 book ai didi

python - Pytesseract : "TesseractNotFound Error: tesseract is not installed or it' s not in your path", 我该如何解决这个问题?

转载 作者:太空狗 更新时间:2023-10-29 21:12:26 24 4
gpt4 key购买 nike

我正在尝试在 python 中运行一个基本且非常简单的代码。

from PIL import Image
import pytesseract

im = Image.open("sample1.jpg")

text = pytesseract.image_to_string(im, lang = 'eng')

print(text)

这就是它的样子,我实际上已经通过安装程序安装了 tesseract for windows。我是 Python 的新手,我不确定如何继续?

此处的任何指导都会非常有帮助。我试过重新启动我的 Spyder 应用程序但无济于事。

最佳答案

我看到步骤分散在不同的答案中。根据我最近在 Windows 上遇到此 pytesseract 错误的经验,按顺序编写不同的步骤以更容易地解决错误:

1。使用 Windows 安装程序安装 tesseract,网址为:https://github.com/UB-Mannheim/tesseract/wiki

2。注意安装中的 tesseract 路径。此编辑时的默认安装路径为:C:\Users\USER\AppData\Local\Tesseract-OCR。它可能会改变,所以请检查安装路径。

3pip 安装 pytesseract

4。在调用 image_to_string 之前在脚本中设置 tesseract 路径:

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\USER\AppData\Local\Tesseract-OCR\tesseract.exe'

关于python - Pytesseract : "TesseractNotFound Error: tesseract is not installed or it' s not in your path", 我该如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50951955/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com