0

I am using pytesseract's OCR to make a typing-related bot. I use pyautogui to take the screenshot and then run it through tesseract. But, when I try to turn the image into a string it returns this error message.

Traceback (most recent call last):
  File "e:\Coding and Shiatzu\drawing_game_bot.py", line 48, in <module>
    guess('g')
  File "e:\Coding and Shiatzu\drawing_game_bot.py", line 31, in guess
    word = pytesseract.image_to_string(img)
  File "C:\Users\MYNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytesseract\pytesseract.py", line 416, in image_to_string
    return {
  File "C:\Users\MYNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytesseract\pytesseract.py", line 419, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:\Users\MYNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytesseract\pytesseract.py", line 286, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:\Users\MYNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytesseract\pytesseract.py", line 257, in run_tesseract
    raise e
  File "C:\Users\MYNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytesseract\pytesseract.py", line 254, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied

This is the code I'm running:

pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\MYNAME\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\pytesseract'
img = screenshot(region = (500, 75, 400, 100))
word = pytesseract.image_to_string(img)
print(word)

0 Answers0