gpt4 book ai didi

python - pytesseract 错误 Windows 错误 [错误 2]

转载 作者:太空宇宙 更新时间:2023-11-03 13:34:44 27 4
gpt4 key购买 nike

您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码:

from PIL import Image
from pytesseract import image_to_string
print image_to_string(Image.open(r'D:\new_folder\img.png'))

但是出现如下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

我没有找到具体的解决方案。任何人都可以帮我做什么。还有什么要下载的,或者我可以从哪里下载等等。

提前致谢:)

最佳答案

我遇到了同样的麻烦,看完这篇文章后很快找到了解决方案:

OSError: [Errno 2] No such file or directory using pytesser

只需要适配Windows,替换如下代码:

tesseract_cmd = 'tesseract'

与:

tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'

(需要双\\转义字符串中第一个\)

关于python - pytesseract 错误 Windows 错误 [错误 2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41652335/

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