title: How do I force pytesseract to output numbers only?
body: <p>I have a program that reads numbers, but sometimes it recognizes them as other random characters, which is my problem. Besides filtering the output afterwards, is there any way to make pytesseract output numbers only?</p>
  
  <p>I have tried:</p>
  
  <pre><code>text = pytesseract.image_to_string(Image.open(filename),config='outputbase digits')
  </code></pre>
  
  <pre><code>text = pytesseract.image_to_string(Image.open(filename),config='outputbase nobatch digits')
  </code></pre>
  
  <p>and</p>
  
  <pre><code>text = pytesseract.image_to_string(Image.open(filename),config='tessedit_char_whitelist 0123456789')
  </code></pre>
  
  <p>None of the give errors, but they don't alter the output as expected eighter.</p>
  
  <p>At this point I'm desperate, any help will be apreciated! :)</p>
  
  <p><strong>Edit:</strong>
  I got the result i hoped for by manually removing all non numbers from the font with <a href="https://fontforge.github.io/en-US/" rel="nofollow noreferrer">FontForge</a> and then creating the .trainerdata file with <a href="http://trainyourtesseract.com/" rel="nofollow noreferrer">http://trainyourtesseract.com/</a>.</p>
  
  <p>This method should work regardless of what characters you want to whitelist, as you can just remove them</p>