WindowsError:[Error 2]系统找不到为pytess指定的文件

2024-10-01 04:53:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pytesseract进行OCR,但遇到一个windows错误。请帮忙。在

from PIL import Image
from pytesseract import image_to_string
import matplotlib.pyplot as plt

正在加载图像

^{pr2}$

打印文本

print(image_to_string(im,lang='eng'))

我得到以下错误

Traceback (most recent call last):


 File "C:/Users/amuly/PycharmProjects/P1/Teeth_detection/test1.py", line 17, in <module>
    print(image_to_string(im,lang='eng'))
  File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
    config=config)
  File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Tags: toinpyimageimportstringlib错误
1条回答
网友
1楼 · 发布于 2024-10-01 04:53:54

你必须确保tesseract.exe文件在您的计算机上(例如,通过安装Tesseract OCR),然后将包含文件夹添加到PATH环境变量,或使用声明其位置

import pytesseract
pytesseract.pytesseract.tesseract_cmd attribute

相关问题 更多 >