title: Annoying python tesseract error Error opening data file ./tessdata/eng.traineddata
body: <p>I'm bumping into this error that's driving me a little bit crazy with the python wrapper for tesseract which is a python module called tesseract.</p>
  
  <p>Here's the python code I am trying to run :</p>
  
  <pre><code>img = cv2.imread(image, 0)
  api = tesseract.TessBaseAPI()
  api.Init(".","eng",tesseract.OEM_DEFAULT)
  api.SetPageSegMode(tesseract.PSM_AUTO)
  tesseract.SetCvImage(img,api)
  url = api.GetUTF8Text()
  conf=api.MeanTextConf()
  print('Extracted URL : ' + url)
  api.End()
  </code></pre>
  
  <p>and this is what I get:</p>
  
  <pre><code>Error opening data file ./tessdata/eng.traineddata
  Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
  Failed loading language 'eng'
  Tesseract couldn't load any languages!
  </code></pre>
  
  <p>I don't understand why it is doing this since I have the TESSDATA_PREFIX env variable correctly set to the correct path to my tesseract installation (with the trailing slash).</p>
  
  <p>When I try to run Tesseract directly from powershell (I'm on windows 7 btw), by doing:</p>
  
  <pre><code> tesseract.exe .\data\test.tif -psm 7 out
  </code></pre>
  
  <p>it works like a charm !
  Also when I call Tesseract with Popen in my python script it works fine but I don't like the idea of me not being able to grab the OCR'd text directly from stdout. Indeed, there seems to be no other choice than providing Tesseract with an output filename and then to fopen and read from that file. I feel it's going to be pretty awful to deal with temporary text files just to get the output of the OCR...</p>
  
  <p>Help? </p>