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.

Files for tesserpy, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size tesserpy-1.1.1.tar.gz (7.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page