Running the sample code in pytesseract
<p>I am running python 2.6.6 and want to install the <a href="https://pypi.python.org/pypi/pytesseract" rel="nofollow">pytesseract</a> package. After extraction and installation, I can call the pytesseract from the command line. However I want to run the tesseract within python. I have the following code (ocr.py):</p>

<pre><code>try:
     import Image
except ImportError:
     from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('test.png')))
print(pytesseract.image_to_string(Image.open('test-european.jpg'),lang='fra'))
</code></pre>

<p>When I run the code by python ocr.py, I get the following output:</p>

<pre><code>Traceback (most recent call last):
  File "ocr.py", line 6, in &lt;module&gt;
    print(pytesseract.image_to_string(Image.open('test.png')))
  File "/pytesseract-0.1.6/build/lib/pytesseract/pytesseract.py", line 164, in image_to_string
    raise TesseractError(status, errors)
pytesseract.TesseractError: (2, 'Usage: python tesseract.py [-l language] input_file')
</code></pre>

<p>test.png and test-european.jpg are in the working directory. Can Someone help me running this code?
I have tried the following:</p>

<ol>
<li>Adjusted the tesseract_cmd to 'pytesseract'</li>
<li>Installed tesseract-ocr</li>
</ol>

<p>Any help is appreciated as I am trying to solve this problem for hours now.</p>

<p><code>tesseract_cmd</code> should point to the command line program <a href="https://github.com/tesseract-ocr/tesseract" rel="nofollow"><code>tesseract</code></a>, not <code>pytesseract</code>.</p>

<p>For instance on Ubuntu you can install the program using:</p>

<pre><code>sudo apt install tesseract-ocr
</code></pre>

<p>And then set the variable to just <code>tesseract</code> or <code>/usr/bin/tesseract</code>.</p>

python tesseract python-tesseract