[Python] Receiving "pytesseract not in your path" error on the exact same code that used to...

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I wrote this code several months ago and wanted to pass through it to clean it up and add some new features. Its a simple tool I used to take a picture of my screen and get write-able words from it. I am on a new computer from the one I originally wrote the code on; however, I went through and installed every module via the pycharm module manager. However, I keep getting this error when I run the code even though I have located the package in my path. Any help would be greatly appreciated.

    I've looked up several different variations of my problem but they all seem to have different causes and fixes, of course, none of which work for me.

    if c ==2:
    img = ImageGrab.grab(bbox=(x1-5, y1-5, x2+5,y2+5)) # bbox specifies region (bbox= x,y,width,height)
    img_np = np.array(img)
    frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2GRAY)
    c = 0
    x = 0
    string = str(pytesseract.image_to_string(frame)).lower()
    print(string)


    This is the only section of the code that references pytesseract other than of course "import pytesseract". Hopefully I can get this code up and running again and the pytesseract module in general as it is integral to many of my scripts. Thanks in advance for your help.

    File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 184, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
    File "C:\Users\dante\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
    File "C:\Users\dante\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:/Users/dante/Desktop/DPC/processes/screen_to_text.py", line 29, in <module>
    string = str(pytesseract.image_to_string(frame)).lower()
    File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
    }[output_type]()
    File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
    File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
    run_tesseract(**kwargs)
    File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 186, in run_tesseract
    raise TesseractNotFoundError()
    pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path```

    Continue reading...

Compartilhe esta Página