Python pytesseract nefunguje

Milan Horák milan na nosoftware.cz
Čtvrtek Říjen 12 19:31:35 CEST 2023


Zdravím,

není to náhodou tohle:

---
The problem was in my lack of understanding of the module. pytesseract 
is not an OCR, it is simply a translator that allows users to use 
googles OCR. This means, in order to use this package, a user must have 
google's OCR installed ( I downloaded mine from here 
https://sourceforge.net/projects/tesseract-ocr-alt/files/).

This does NOT; however, solve the full problem. The pytesseract package 
needs to know where the actual OCR program is located. On line 35 of the 
pytesseract.py script there is a line that tells pytesseract where to 
find the actual google OCR tesseract program

tesseract_cmd = 'tesseract'

If you are on windows and you haven't manually added tesseract to your 
path (if you don't know what that means just follow the next steps) then 
you need to replace that line with the actual location of the google OCR 
on your computer. Replacing that line with

tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'

should allow you to run pytesseract assuming you have correctly 
installed everything. Took me quite a bit longer than i would care to 
admit to find the blatantly obvious solution to this issue, but 
hopefully people with this problem in the future resolve it faster than 
I did! Thanks and have a good day.
---

https://stackoverflow.com/questions/55582511/receiving-pytesseract-not-in-your-path-error-on-the-exact-same-code-that-used

Milan

Dne 12. 10. 23 v 18:20 Pavel Hudeček napsal(a):
> Dobrý den všem,
> 
> udělal jsem
> *pip install pytesseract*
> Skončilo to
> /Successfully installed pytesseract-0.3.10/
> 
> Spustil jsem program:
> fromPIL importImage importpytesseract img = Image.open('W130_Final.PNG') 
> text = pytesseract.image_to_string(img) print(text)
> A výsledek je:
> /Traceback (most recent call last)://
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract//
> //    proc = subprocess.Popen(cmd_args, **subprocess_args())//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 800, in __init__//
> //    restore_signals, start_new_session)//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1207, in _execute_child//
> //    startupinfo)//
> //FileNotFoundError: [WinError 2] Systém nemůže nalézt uvedený soubor//
> //
> //During handling of the above exception, another exception occurred://
> //
> //Traceback (most recent call last)://
> //  File "exp-xls.py", line 4, in <module>//
> //    text = pytesseract.image_to_string(img)//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", line 427, in image_to_string//
> //    }[output_type]()//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>//
> //    Output.STRING: lambda: run_and_get_output(*args),//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output//
> //    run_tesseract(**kwargs)//
> //  File 
> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", line 260, in run_tesseract//
> //    raise TesseractNotFoundError()//
> //pytesseract.pytesseract.TesseractNotFoundError: tesseract is not 
> installed or it's not in your PATH. See README file for more information./
> 
> Příčemž v path je mimo jiné
> C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\
> kde se nachází i soubor pytesseract.py
> A readme jsem nenašel.
> 
> Zkoušel jsem restartovat počítač a taky nepomohlo. Ostatní asi 4 věci co 
> jsem dnes instaloval přes pip normálně fungují
> 
> Nějaké nápady?
> 
> Díky,
> PH
> 
> 
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list


Další informace o konferenci Hw-list