Title: Installing Tesseract, PyTesseract, and Python OCR packages on your system - PyImageSearch

URL Source: https://pyimagesearch.com/2021/08/16/installing-tesseract-pytesseract-and-python-ocr-packages-on-your-system/

Published Time: 2021-08-16T14:00:00+00:00

Markdown Content:
In this tutorial, we will _configure_ our development environment for OCR. Once your machine is configured, we’ll start writing Python code to perform OCR, paving the way for you to develop your own OCR applications.

A text-image dataset is useful when installing and testing Tesseract and PyTesseract. It helps in verifying the successful installation and allows for the initial exploration of these OCR tools.

[Roboflow](https://roboflow.com/?ref=pyimagesearch) has free tools for each stage of the computer vision pipeline that will streamline your workflows and supercharge your productivity.

Sign up or Log in to your [Roboflow account](https://roboflow.com/?ref=pyimagesearch) to access state of the art dataset libaries and revolutionize your computer vision pipeline.

You can start by choosing your own datasets or using our [PyimageSearch’s assorted library of useful datasets](https://universe.roboflow.com/pyimagesearch?ref=pyimagesearch).

Bring data in any of 40+ formats to [Roboflow](https://roboflow.com/?ref=pyimagesearch), train using any state-of-the-art model architectures, deploy across multiple platforms (API, NVIDIA, browser, iOS, etc), and connect to applications or 3rd party tools.

![Image 1](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20700%20393'%3E%3C/svg%3E)

**To learn how to configure your development environment,** **_just keep reading._**

**Learning Objectives**
-----------------------

In this tutorial, you will:

1.  Learn how to install the Tesseract OCR engine on your machine
2.  Learn how to create a Python virtual environment (a best practice in Python development)
3.  Install the necessary Python packages you need to run the examples in this tutorial (and develop OCR projects of your own)

**OCR Development Environment Configuration**
---------------------------------------------

In the first part of this tutorial, you will learn how to install the Tesseract OCR engine on your system. From there, you’ll learn how to create a Python virtual environment and then install OpenCV, PyTesseract, and all the other necessary Python libraries you’ll need for OCR, computer vision, and deep learning.

### **A Note on Install Instructions**

The Tesseract OCR engine has existed for over 30 years. The install instructions for Tesseract OCR are fairly stable. Therefore I have included the steps.

With that said, let’s install the Tesseract OCR engine on your system!

### **Installing Tesseract**

Inside this tutorial, you will learn how to install Tesseract on your machine.

#### **Installing Tesseract on macOS**

Installing the Tesseract OCR engine on macOS is quite simple if you use the [Homebrew](https://brew.sh/) package manager.

Use the link above to install Homebrew on your system if it is not already installed.

From there, all you need to do is use the `brew` command to install Tesseract:

 $ brew install tesseract

Provided that the above command does not exit with an error, you should now have Tesseract installed on your macOS machine.

#### **Installing Tesseract on Ubuntu**

Installing Tesseract on Ubuntu 18.04 is easy — all we need to do is utilize `apt-get`:

 $ sudo apt install tesseract-ocr

The `apt-get` package manager will automatically install any prerequisite libraries or packages required for Tesseract.

#### **Installing Tesseract on Windows**

Please note that the PyImageSearch team and I _do not_ officially support Windows, except for customers who use our pre-configured Jupyter/Colab Notebooks, which you can find at [PyImageSearch University](https://pyimagesearch.com/pyimagesearch-university/). These notebooks run on all environments, including macOS, Linux, and Windows.

**We instead recommend using a Unix-based machine such as Linux/Ubuntu or macOS**, both of which are better suited for developing computer vision, deep learning, and OCR projects.

That said, if you wish to install Tesseract on Windows, we recommend that you follow the official Windows install instructions put together by the [Tesseract team](https://github.com/tesseract-ocr/tessdoc).

#### **Verifying Your Tesseract Install**

Provided that you were able to install Tesseract on your operating system, you can verify that Tesseract is installed by using the `tesseract` command:

 $ tesseract -v
 tesseract 4.1.1
  leptonica-1.79.0
   libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.11 : libwebp 1.1.0 : libopenjp2 2.3.1
  Found AVX2
  Found AVX
  Found FMA
  Found SSE

Your output should look similar to mine.

### **Creating a Python Virtual Environment for OCR**

Python virtual environments are a best practice for Python development, and we recommend using them to have more reliable development environments.

Installing the necessary packages for Python virtual environments, as well as creating your first Python virtual environment, can be found in our [_pip Install OpenCV_](https://pyimagesearch.com/2018/09/19/pip-install-opencv/) tutorial. We recommend you follow that tutorial to create your first Python virtual environment.

### **Installing OpenCV and PyTesseract**

Now that you have your Python virtual environment created and ready, we can install both OpenCV and PyTesseract, the Python package that interfaces with the Tesseract OCR engine.

Both of these can be installed using the following commands:

 $ workon <name\_of\_your\_env> # required if using virtual envs
 $ pip install numpy opencv-contrib-python
 $ pip install pytesseract

Next, we’ll install other Python packages we’ll need for OCR, computer vision, deep learning, and machine learning.

### **Installing Other Computer Vision, Deep Learning, and Machine Learning Libraries**

Let’s now install some other supporting computer vision and machine learning/deep learning packages that we’ll need throughout the rest of this tutorial:

 $ pip install pillow scipy
 $ pip install scikit-learn scikit-image
 $ pip install imutils matplotlib
 $ pip install requests beautifulsoup4
 $ pip install h5py tensorflow textblob

### What's next? We recommend [PyImageSearch University](https://pyimagesearch.com/pyimagesearch-university/?utm_source=blogPost&utm_medium=bottomBanner&utm_campaign=What%27s%20next%3F%20I%20recommend).

**Course information:**  
84 total classes • 114+ hours of on-demand code walkthrough videos • Last updated: February 2024  
★★★★★ 4.84 (128 Ratings) • 16,000+ Students Enrolled

**I strongly believe that if you had the right teacher you could _master_ computer vision and deep learning.**

Do you think learning computer vision and deep learning has to be time-consuming, overwhelming, and complicated? Or has to involve complex mathematics and equations? Or requires a degree in computer science?

That’s _not_ the case.

All you need to master computer vision and deep learning is for someone to explain things to you in _simple, intuitive_ terms. _And that’s exactly what I do_. My mission is to change education and how complex Artificial Intelligence topics are taught.

If you're serious about learning computer vision, your next stop should be PyImageSearch University, the most comprehensive computer vision, deep learning, and OpenCV course online today. Here you’ll learn how to _successfully_ and _confidently_ apply computer vision to your work, research, and projects. Join me in computer vision mastery.

**Inside PyImageSearch University you'll find:**

*   ✓ **84 courses** on essential computer vision, deep learning, and OpenCV topics
*   ✓ **84 Certificates** of Completion
*   ✓ **114+ hours** of on-demand video
*   ✓ **Brand new courses released _regularly_**, ensuring you can keep up with state-of-the-art techniques
*   ✓ **Pre-configured Jupyter Notebooks in Google Colab**
*   ✓ Run all code examples in your web browser — works on Windows, macOS, and Linux (no dev environment configuration required!)
*   ✓ Access to **centralized code repos for _all_ 536+ tutorials** on PyImageSearch
*   ✓ **Easy one-click downloads** for code, datasets, pre-trained models, etc.
*   ✓ **Access** on mobile, laptop, desktop, etc.

[Click here to join PyImageSearch University](https://pyimagesearch.com/pyimagesearch-university/?utm_source=blogPost&utm_medium=bottomBanner&utm_campaign=What%27s%20next%3F%20I%20recommend)

**Summary**
-----------

In this tutorial, you learned how to install the Tesseract OCR engine on your machine. You also learned how to install the required Python packages you will need to perform OCR, computer vision, and image processing.

Now that your development environment is configured, we will write an OCR code in our next tutorial!

![Image 2](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20410%20567'%3E%3C/svg%3E)

#### Join the PyImageSearch Newsletter and Grab My FREE 17-page Resource Guide PDF

Enter your email address below to **join the PyImageSearch Newsletter** and **download my FREE 17-page Resource Guide PDF** on Computer Vision, OpenCV, and Deep Learning.