Latest version


Python-tesseract is a python wrapper for Google's Tesseract-OCR

Project description

Python-tesseract is an optical character recognition (OCR) tool for python.That is, it will recognize and “read” the text embedded in images.

Python-tesseract is a wrapper for Google’s Tesseract-OCR Engine.It is also useful as a stand-alone invocation script to tesseract, as it can read all image typessupported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff,and others. Additionally, if used as a script, Python-tesseract will print the recognizedtext instead of writing it to a file.



Sudo apt install tesseract-ocr Note that this will only work on Ubuntu. Sudo is a Unix exclusive command (Linux, Mac, Rasbian, etc.) while apt is Ubuntu specific.

  1. Python-tesseract for Python is an optical character recognition (OCR). That is, it will recognize and “read” the text embedded in the images. For Python: pip install pytesseract. For Mac Users $ brew install tesseract. For Linux users: $ sudo apt-get install tesseract-ocr.
  2. All that command does is download and install language (i.e. Typeface with language-specific dictionary) training from the Google website and install it in the tessdata/ folder in tesseract-ocr/. We can do the same thing by hand by downloading any language training from various websites ( Google Code or eMOP Github for example) and putting it.
  3. Download Tesseract OCR for free. Open Source OCR Engine. Tesseract is an open source OCR or optical character recognition engine and command line program. OCR is a technology that allows for the recognition of text characters within a digital image.

Note: Test images are located in the tests/data folder of the Git repo.

Library usage:

Support for OpenCV image/NumPy array objects

If you need custom configuration like oem/psm, use the config keyword.

Add the following config, if you have tessdata error like: “Error opening data file…”


  • get_tesseract_version Returns the Tesseract version installed in the system.
  • image_to_string Returns the result of a Tesseract OCR run on the image to string
  • image_to_boxes Returns result containing recognized characters and their box boundaries
  • image_to_data Returns result containing box boundaries, confidences, and other information. Requires Tesseract 3.05+. For more information, please check the Tesseract TSV documentation
  • image_to_osd Returns result containing information about orientation and script detection.
  • image_to_alto_xml Returns result in the form of Tesseract’s ALTO XML format.
  • run_and_get_output Returns the raw output from Tesseract OCR. Gives a bit more control over the parameters that are sent to tesseract.

See Full List On


image_to_data(image, lang=None, config=', nice=0, output_type=Output.STRING, timeout=0, pandas_config=None)

  • image Object or String - PIL Image/NumPy array or file path of the image to be processed by Tesseract. If you pass object instead of file path, pytesseract will implicitly convert the image to RGB mode.
  • lang String - Tesseract language code string. Defaults to eng if not specified! Example for multiple languages: lang='eng+fra'
  • config String - Any additional custom configuration flags that are not available via the pytesseract function. For example: config='--psm 6'
  • nice Integer - modifies the processor priority for the Tesseract run. Not supported on Windows. Nice adjusts the niceness of unix-like processes.
  • output_type Class attribute - specifies the type of the output, defaults to string. For the full list of all supported types, please check the definition of pytesseract.Output class.
  • timeout Integer or Float - duration in seconds for the OCR processing, after which, pytesseract will terminate and raise RuntimeError.
  • pandas_config Dict - only for the Output.DATAFRAME type. Dictionary with custom arguments for pandas.read_csv. Allows you to customize the output of image_to_data.

CLI usage:



  • Python-tesseract requires Python 2.7 or Python 3.5+

  • You will need the Python Imaging Library (PIL) (or the Pillow fork).Under Debian/Ubuntu, this is the package python-imaging or python3-imaging.

  • Install Google Tesseract OCR(additional info how to install the engine on Linux, Mac OSX and Windows).You must be able to invoke the tesseract command as tesseract. If thisisn’t the case, for example because tesseract isn’t in your PATH, you willhave to change the “tesseract_cmd” variable pytesseract.pytesseract.tesseract_cmd.Under Debian/Ubuntu you can use the package tesseract-ocr.For Mac OS users. please install homebrew package tesseract.

    Note: Make sure that you also have installed tessconfigs and configs from tesseract-ocr/tessconfigs or via the OS package manager.

Check the pytesseract package page for more information.


To run this project’s test suite, install and run tox. Ensure that you have tesseractinstalled and in your PATH.


Check the LICENSE file included in the Python-tesseract repository/distribution.As of Python-tesseract 0.3.1 the license is Apache License Version 2.0


  • Originally written by Samuel Hoffstaetter

Release historyRelease notifications RSS feed
























Tesseract ocr windows 10

Download files

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

Files for pytesseract, version 0.3.6
Filename, sizeFile typePython versionUpload dateHashes
Filename, size pytesseract-0.3.6.tar.gz (13.4 kB) File type Source Python version None Upload dateHashes

Hashes for pytesseract-0.3.6.tar.gz

Hashes for pytesseract-0.3.6.tar.gz
AlgorithmHash digest

Scanning images with OCR (Optical Character Recognition) is immensely helpful to findwhat you're looking for later solely by using the text in the image when searching.OCR is big money, so of course, there's no easy way to do it with a nice UI. Many ofthese apps cost $10, $20, or more, which is unreasonable.

Tesseract is a free, open-source OCR application that many of the paid apps 'borrow',repackage, and sell at a high mark up. Unfortunately, when I say application, I meana command line interface. So, it's not terribly intuitive. But we can simplify it.And in the process, spite Adobe and others for trying to resell something that's soincredibly helpful:

Open the Terminal app, type, and hit enter to install tesseract.

If that didn't work, you don't have Homebrew installed, and you need to run thefollowing command:

this comes from the Homebrew website. It's basically a packagemanager like apt or apt-get that installs ('brews') applications for you.

Now, we need to add an aliased command. We can do that with.

Gets you to script that runs every time you start a bash shell.

Tesseract Ocr For Windows

On MacOS, you might be using the new, default zsh (Z shell). I recommend youswitch back to bash (since it's superior) by

  1. Clicking Terminal in the upper-left hand corner
  2. Click 'Preferences...'
  3. Shells open with
  4. Enter in the command field /bin/bash. Restart Terminal, and retry the above command.

Now, in the .bash_profile file, append at the bottom of the file

This basically means that every time you run the aliased command convertpdf,bash will run every file in the current directory through tesseract.

Hit Ctrl + X, and hit y and Enter to save the file.

Restart Terminal. Congratulations, its setup!

Use Example

Now say you took a lot of screenshots of something. Putthem in a folder on your Desktop. Lets say you called this folder on yourDesktop screenshots. Open the Terminal app, and change directory(cd Desktop/screenshots/) to it. Once in that folder, just type convertpdf,and every image will be converted to a PDF.

Tesseract Ocr Download Mac

The Sad Facts

Tesseract is a one-trick pony, so it only converts images. And if you usethat exact command, it will convert those images to PDFs with overlayed,searchable text. A gold standard that not many 'free' OCR converters dofor you online.

What's bad is that it converts every single image to its own individualPDF. And now you have a new problem: You probably want to combine the PDFsinstead of having tens or hundreds of PDFs of the same document.

Unfortunately, there's no app on the Mac App Store that is:

Tesseract Ocr Download Windows

  1. Free
  2. Does NOT contain in-app purchases
  3. Combines PDFs
  4. Preserves the text overlay layer that makes searchable PDFs actually useful

This seems like a supremely low bar to hit, but life is often disappointing.You might think the 'free' Adobe Acrobat program might be able to combine PDFs.Since, you know, Adobe invented PDFs in 1993,and they're widely used. About 20% of the Panama Papers were PDFs.But unfortunately, the 500 megabyte Adobe Acrobat program will not combine PDFsunless you A) sign into an Adobe account, and B) pay the same cost as a monthly Netflix subscription.

The native Preview can let you combine PDFs, but it doesn't preserve the text overlaylayer.

There are other hacky solutions like this online, like this gist of a shell script,this repo of a Python script,and others. But I tested the Python script, it doesn't work (even with sometinkering.) The shell script looks over-engineered. The solutoin presentedhere is simple and general enough that it should work across different macOSes,and hopefully into the future.

I recommend you just organize these many PDFs into a folder, name it smart, andit will be helpful when searching for it, later.