#pyteseract image_to_string function not working

11 messages · Page 1 of 1 (latest)

ember turretBOT
#

@fleet pumice

File Attachments Not Allowed

For safety reasons we do not allow file and video attachments.

banom Said

operating system mac osx : 10.13.6
python : Python 3.10.11
am using pycharm

i am trying to do a simple code where i capture a picture on the screen with Pillow (PIL) ImageGrab function and using Tesseract convert the text/numbers on that image to string

the image capture with pillow works just fine
but when i try to use tesseract to convert it to string it shows error

CODE

from PIL import ImageGrab
import pytesseract

screenshot = ImageGrab.grab(bbox=(332,105,545,150))
screenshot.save("screenshot.png")

text = pytesseract.image_to_string('screenshot.png')
print(text)

i attatched a file showing the error that appears

Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files
  • Error_file.rtf
#

@fleet pumice

banom Uploaded Some Code
Uploaded these files to a Gist
fleet pumice
#

/usr/local/bin/python3.10 /Users/mohamdessam/Desktop/Python/TESTING501/main.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/mohamdessam/Desktop/Python/TESTING501/main.py", line 7, in <module>
text = pytesseract.image_to_string('screenshot.png')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 423, in image_to_string
return {
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 426, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 288, in run_and_get_output
run_tesseract(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 260, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.

Process finished with exit code 1

fleet pumice
#

after searching i found people saying that i need to install it with brew as well

#

so i ran brew install tesseract

#

and there was a proplem with the installation

ember turretBOT
#

@fleet pumice

banom Uploaded Some Code
Uploaded these files to a Gist
fleet pumice
fleet pumice
#

so i am stuck