Export to GitHub

pytesser - issue #2

calling image_to_string errs at subprocess.py


Posted on Jul 25, 2007 by Happy Hippo

What steps will reproduce the problem? >>> from pytesser import * >>> import Image >>>im=Image.open('C:\Python24\Lib\site-packages\pytesser\phototest.tif') >>> text=image_to_string(im) Traceback (most recent call last): File "<stdin>", line 1, in ? File "C:\Python24\lib\site-packages\pytesser\pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "C:\Python24\lib\site-packages\pytesser\pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "C:\Python24\lib\subprocess.py", line 542, in init errread, errwrite) File "C:\Python24\lib\subprocess.py", line 706, in _execute_child startupinfo) WindowsError: [Errno 2] The system cannot find the file specified >>>

Comment #1

Posted on Aug 6, 2007 by Helpful Giraffe

Comment deleted

Comment #2

Posted on Aug 6, 2007 by Helpful Bear

In this version of PyTesser, the installation files must be in the same directory as the script importing PyTesser. Later versions will be more suitable for installing in site-packages, or at least more explicit about usage limitations.

Comment #3

Posted on Jun 17, 2008 by Happy Elephant

I get this too.

from pytesser import * import Image im=Image.open('phototest.tif') text=image_to_string(im) Traceback (most recent call last): File "", line 1, in ? File "/home/shemtov/afik/pyt/pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "/home/shemtov/afik/pyt/pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "/usr/local/lib/python2.4/subprocess.py", line 542, in init errread, errwrite) File "/usr/local/lib/python2.4/subprocess.py", line 975, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

The installation files are in the same directory as the script i'm trying to, use, and this should be even a moot point because I'm using the interpreter and it isn't working. What am I missing?

Comment #4

Posted on Jun 18, 2008 by Helpful Giraffe

It looks like you're using *NIX. PyTesser was developed for Windows--it might work in *NIX if you substitute a native Tesseract executable, but you'll have to be careful about filenames.

Comment #5

Posted on Jul 16, 2008 by Quick Bird

Comment deleted

Comment #6

Posted on Mar 8, 2010 by Swift Rabbit

i have exactly the same problems does having windows 7 make a difference??

Comment #7

Posted on Mar 22, 2010 by Quick Lion

I'm on Windows 7 and having exactly the same problem. I have tried setting tesseract.exe to run in compatibility with earlier versions of Windows, and as administrator.

Comment #8

Posted on Jul 23, 2010 by Massive Elephant

This is just horrible... how is this not working in Linux in Python? Have you never heard of os independant path's? hm...

Comment #9

Posted on Sep 7, 2010 by Happy Bear

works fine in linux as long as tesseract executable is in PATH :) Tested on Ubuntu 10.04 and CentOS 5.4

Comment #10

Posted on Apr 20, 2011 by Helpful Ox

Comment deleted

Comment #11

Posted on Apr 20, 2011 by Helpful Ox

Please help I get the same error with MAC OSx and python 2.6

File "ex.py", line 3, in print image_to_string(image) # Run tesseract.exe on image File "/Users/gabrielcarneironovaes/Sites/python/pytesser/pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "/Users/gabrielcarneironovaes/Sites/python/pytesser/pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "/Applications/MAMP/python/framework/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in init errread, errwrite) File "/Applications/MAMP/python/framework/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

Comment #12

Posted on Aug 24, 2011 by Grumpy Horse

i got the same error, im running on Ubuntu 11.04 with python 2.7

Traceback (most recent call last): File "test.py", line 15, in pytesser.image_to_string(data) File "/home/jose/Documentos/Geek/pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "/home/jose/Documentos/Geek/pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "/usr/lib/python2.7/subprocess.py", line 672, in init errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1213, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

Comment #13

Posted on Oct 1, 2011 by Swift Giraffe

Another one of those "Doesn't work the way it's ****ing suppose to." A quick "I'll have this script ready in a few minutes" turned into a "My eyes are strained because I'v been staring at the damn screen for the past 3 hours trying to solve the same problem everybody else is experiencing above me"

It doesn't seem like anybody cared enough to guide us through a problem that's been going around since 2007 (it's 2011 now)....

Comment #14

Posted on Nov 28, 2011 by Grumpy Hippo

same problme here, windows7 32bit, Python2.6

Comment #15

Posted on Nov 29, 2011 by Happy Elephant

Comment deleted

Comment #16

Posted on May 24, 2012 by Happy Rhino

There's an easy work around for this if you're using the pytesser directory as a submodule (you've added an empty init.py file):

Change this line in pytesser.py (line 13): tesseract_exe_name = 'tesseract'

to this: tesseract_exe_name = os.path.dirname(file) + '/tesseract'

That way it will look in the correct place for the executable.

Comment #17

Posted on Mar 14, 2013 by Swift Ox

The program 'tesseract' is currently not installed. You can install it by typing:

sudo apt-get install tesseract-ocr

Comment #18

Posted on Jun 20, 2014 by Quick Bird

Email #17 by skipp...@gmail.com was the answer for me.

Comment #19

Posted on Nov 8, 2014 by Helpful Monkey

I know why this happend:

because the python script use the command: tesseract, accutally like this: ./tesseract input-image but you do not install "tesseract", so it told you : The system cannot find the file specified

details:

  1. I's not the python script who "read" the words from the picture, It's a command: "tesseract"
  2. why subprocess? because, the python execute the cmd use multi-process, the equal effect codes are like this: os.system("tesseract -input_pic, -output_words ) ,

Comment #20

Posted on Jun 27, 2015 by Massive Panda

For the next person who struggles with this, open pytesser.py and the first line that says:

Import Image

Change this to

from PIL import Image

solved my issue.

Status: Accepted

Labels:
Type-Defect Priority-Medium