1

I'm currently on a ubuntu-environment and facing a problem when using tesseract and pycharm.

So i get the error mentioned in the Title when i try to run following code in pycharm:

import cv2
import opencv
import pytesseract

image = cv2.imread('assets/alugas/alugas.jpeg')
img_rgb = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img_rgb,lang='eng'))

cv2.waitKey(0)

tesseract -v gives me:

tesseract -v
tesseract 4.1.1
 leptonica-1.79.0
  libgif 5.1.9 : libjpeg 8d (libjpeg-turbo 2.0.6) : libpng 1.6.37 : libtiff 4.3.0 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.1
 Found AVX2
 Found AVX
 Found FMA
 Found SSE
 Found libarchive 3.4.3 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.8 liblz4/1.9.2 libzstd/1.4.5

I've searched around and tried to use something like this on top of my code with different paths; pytesseract.pytesseract.tesseract_cmd = r'/usr/share/tesseract-ocr/'

EDIT: i have also tried everything here on SO, but most of the solutions given only works on windows it seems..

kirkegaard
  • 1,058
  • 2
  • 12
  • 32
  • Ok, so i found out that my tesseract file is in usr/bin -directory. and when add the path "usr/bin" i get "PermissionError: [Errno 13] Permission denied: '/usr/bin/'" – kirkegaard Jan 04 '22 at 12:43

2 Answers2

0

I'm not sure if i handled it correctly. But i tried to install homebrew and install tesseract that way. after that everything worked. So i guess I'll use homebrew from now on.

kirkegaard
  • 1,058
  • 2
  • 12
  • 32
0

Since you find tesseract file in /usr/bin, did you try adding this line?

pytesseract.pytesseract.tesseract_cmd = "/usr/bin/tesseract"
Thy
  • 468
  • 3
  • 5
  • Yes i tried that as well, but my venv does not have permission to use that. As stated in the answer above, it works with a homebrew-installation. – kirkegaard Jan 05 '22 at 09:23