Python PyteSeract回溯错误

Python PyteSeract回溯错误,python,Python,我是第一次使用Pytesseract,遇到了一个问题。我假设我忽略了一些基本的东西,我仍然在学习python。我在我的计算机上安装了Tesseract OCR,然后对Pyteseract使用了pip安装。我还尝试pip安装pillow,但无法安装,因为它已经通过pyautogui安装。我试图运行下面的代码,但出现了一个错误 问题:我需要更改什么,或者如何更正 回溯: 至于我,Python找不到tesseract.exe 您可能需要手动查找它并将其文件夹添加到路径 顺便说一句:关于pytesser

我是第一次使用Pytesseract,遇到了一个问题。我假设我忽略了一些基本的东西,我仍然在学习python。我在我的计算机上安装了Tesseract OCR,然后对Pyteseract使用了pip安装。我还尝试pip安装pillow,但无法安装,因为它已经通过pyautogui安装。我试图运行下面的代码,但出现了一个错误

问题:我需要更改什么,或者如何更正

回溯:


至于我,Python找不到tesseract.exe

您可能需要手动查找它并将其文件夹添加到路径


顺便说一句:关于pytesseract.py文件中的路径有一些评论,我已经准确地找到了您要说的内容,甚至找到了更改位置,但不完全理解要将其更改为什么。Tesseract.exe位于C:\Program Files x86\Tesseract OCR文件夹中,但它似乎不希望在该变量中包含文件夹目标,因为目前它只是“Tesseract”,我回答了此类问题。
Traceback (most recent call last):
  File "C:\Users\bweibley\HC\test.py", line 20, in <module>
    text = get_text(img, region)
  File "C:\Users\bweibley\HC\test.py", line 8, in get_text
    return pytesseract.image_to_string(image.crop(region))
  File "C:\Users\bweibley\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
    config=config)
  File "C:\Users\bweibley\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
    stderr=subprocess.PIPE)
  File "C:\Users\bweibley\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\bweibley\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
#python 3.6
from PIL import Image
import pytesseract

# --- functions ---

def get_text(image, region):
    return pytesseract.image_to_string(image.crop(region))

def get_int(image, region):
    return int(get_text(image, region).replace(',', ''))

# --- main ---

# test on screenshots: 0.jpg ... 9.jpg
for x in range(10):
    img = Image.open('screenshots/{}.jpg'.format(x))

    region = (288, 664, 487, 706)
    text = get_text(img, region)
    print('Name:', text)

    region = (8666, 871, 1036, 920)
    value = get_int(img, region)
    print('Power:', value)

    region = (1292, 466, 1420, 515)
    value = get_int(img, region)
    print('Loot #1:', value)

    region = (1292, 555, 1420, 604)
    value = get_int(img, region)
    print('Loot #2:', value)

    region = (1292, 645, 1420, 694)
    value = get_int(img, region)
    print('Loot #3:', value)

    print('-----')