Search code examples
pythonpython-3.xpermission-denied

PermissionError with pytesseract


My code:

pytesseract.pytesseract.tesseract_cmd = 'C:/Programs/tesseract'
print(pytesseract.image_to_string(Image.open("test.png")))

I get the error: PermissionError: [WinError 5] Access is denied

I then ran the program as administrator, and received the same error. I also changed the permissions of the tesseract folder.

I installed pytesseract using the Python interpreter in Pycharm, and also downloaded the binary from Windows here, using the second option. I extracted the zip folder in C:\Programs

What is causing the error?


Solution

  • Set a TESSDATA_PREFIX in your system variables to your tessdata folder. Mine is C:\Program Files (x86)\Tesseract-OCR\tessdata.

    TESSDATA_PREFIX system variable