cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

pytesseract.pytesseract.TesseractNotFoundError in databricks notebook

neha_ayodhya
New Contributor II

I'm trying to extract the text data from image file in Databricks notebook I have installed below libraries using pip command: %pip install pytesseract tesseract pillow --upgrade

but it didn't work and threw below error pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.

I then installed below the libraries using the libraries section of cluster in Databricks:

  • pillow
  • pytesseract
  • tesseract

But this didn't work too.

later i ran the below shell command in Databricks notebook cell:

%sh

apt-get install -y tesseract-ocr

This command gave me below error: E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Here is my code which i want to run in my databricks notebook:

img=img_path

img_gray = img.convert('L')

text = pytesseract.image_to_string(img_gray)

I want the code to extract the textual data accurately from images Please let me know where am i doing mistake?

1 REPLY 1

shan_chandra
Databricks Employee
Databricks Employee

Hi @neha_ayodhya  - can you please try the following via an init script to the Databricks cluster

sudo apt-get update -y
sudo apt-get install -y tesseract-ocr
sudo apt-get install -y libtesseract-dev
/databricks/python/bin/pip install pytesseract

 and let us know.

Thanks, Shan 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now