madmaze / pytesseract

A Python wrapper for Google Tesseract
Apache License 2.0
5.87k stars 721 forks source link

I've got these error when I tried to compile Pytesseract #25

Closed RoloRoCas closed 9 years ago

RoloRoCas commented 9 years ago

I installed OCR from the google page and I have successfully imported the library Pytesseract, but when I tried to compile this code on python and get these errors from Pytesseract.py and subprocess.py.

My code is:

9 - from pytesseract import image_to_string 10 -from PIL import Image 11- 12- im = Image.open('an91cut.jpg') 13- print(im) 14- 15- print(image_to_string(im))


And the 5 errors are these:

Traceback (most recent call last): File "D:/Documentos/2015-2/Proyecto Electr�nico 1/PycharmProjects/Extracci�n de placa/ocr2.py", line 15, in print(image_to_string(im))

File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 156, in image_to_string status, error_string = run_tesseract(input_file_name,output_file_name_base,lang=lang,boxes=boxes,config=config)

File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 93, in run_tesseract proc = subprocess.Popen(command, stderr=subprocess.PIPE)

File "C:\Python27\lib\subprocess.py", line 706, in init self._execute_child(args, executable, preexec_fn, close_fds,cwd, env, universal_newlines,startupinfo, creationflags, shell,p2cread, p2cwrite,c2pread, c2pwrite, errread, errwrite)

File "C:\Python27\lib\subprocess.py", line 936, in _execute_child hp, ht, pid, tid = _subprocess.CreateProcess(executable, args,None, None,int(not close_fds),creationflags,env,cwd, startupinfo) WindowsError: [Error 5] Acceso denegado

Process finished with exit code 1

HELP PLEASE, I'M DEVELOPING A PROJECT OF LICENSE PLATE RECOGNITION AND MY FRIENDS AND ME ARE DELAYED WITH THE SOLUTION. (Apologize if my English is wrong. Greeting from Peru!)

madmaze commented 9 years ago

I think you may not have "tesseract" in your PATH variables. If you open a terminal and run tesseract does it find it?

I would suggest that you put the full path of where your tesseract binary is located here: https://github.com/madmaze/pytesseract/blob/master/src/pytesseract.py#L60

RoloRoCas commented 9 years ago

Yeeeeeah! It was that! I had written the correct path (tesseract_cmd = C:\Program Files\Tesseract-OCR) but I forgot to write the name of the file "tesseract" and other thing that was wrong is the backslashes. When I was in the directory of "tesseract", I just copied what I got in the adress bar and that was with backslashes, that was causing an error too. I change them to slashes and added the file name of the application "tesseract" and it worked! I put: tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract'. Thanks a lot! @madmaze , you made me to review this code section. Greetings from Perú!!!! :) :)

madmaze commented 9 years ago

Glad hear you have it working.