Skip to main content

Python interface to the Tesseract library

Project description

A Python API for Tesseract


  • Python >= 2.7 or >= 3.2
  • NumPy >= 1.6
  • Tesseract >= 3.02


It’s the usual distutils dance – run python for more details.

If your Tesseract installation’s files are not in the standard system paths, you may need to create a setup.cfg with the following contents:



Here’s a simple example that requires OpenCV:

import cv2
import tesserpy

tess = tesserpy.Tesseract("/path/to/tessdata/prefix", language="eng")
# Anything exposed by SetVariable / GetVariableAsString is an attribute
tess.tessedit_char_whitelist = """'"!@#$%^&*()_+-=[]{};,.<>/?`~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789""""
image = cv2.imread('/path/to/image.png')
page_info = tess.orientation()
print(page_info.textline_order == tesserpy.TEXTLINE_ORDER_TOP_TO_BOTTOM)
print("Word\tConfidence\tBounding box coordinates")
for word in tess.words():
       bb = word.bounding_box
       print("{}\t{}\tt:{}; l:{}; r:{}; b:{}".format(word.text, word.confidence,, bb.left, bb.right, bb.bottom))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tesserpy-1.1.0.tar.gz (7.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page