cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Honored Contributor III
Honored Contributor III

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 

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.