OSError: [WinError 740] The requested operation requires elevation (pytesseract.image_to_string)

135
March 31, 2022, at 06:00 AM

I am having a simple code that has an image called "1.png" and I want to convert it from Image to Text using pytesseract. but, I am having some issues with the code.

import cv2
import pytesseract
img = cv2.imread('1.png')
pytesseract.pytesseract.tesseract_cmd =r"C:\Program Files\Tesseract-OCR\tesseract.exe"
result = pytesseract.image_to_string(img)  

But it's giving me an error.

OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15096/3527021470.py in <module>
----> 1 result = pytesseract.image_to_string(img)
~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in image_to_string(image, lang, config, nice, output_type, timeout)
    411     """
    412     args = [image, 'txt', lang, config, nice, timeout]
--> 413 
    414     return {
    415         Output.BYTES: lambda: run_and_get_output(*(args + [True])),
~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in <lambda>()
    414     return {
    415         Output.BYTES: lambda: run_and_get_output(*(args + [True])),
--> 416         Output.DICT: lambda: {'text': run_and_get_output(*args)},
    417         Output.STRING: lambda: run_and_get_output(*args),
    418     }[output_type]()
~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_and_get_output(image, extension, lang, config, nice, timeout, return_bytes)
    282             'timeout': timeout,
    283         }
--> 284 
    285         run_tesseract(**kwargs)
    286         filename = kwargs['output_filename_base'] + extsep + extension
~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout)
    253         proc = subprocess.Popen(cmd_args, **subprocess_args())
    254     except OSError as e:
--> 255         if e.errno != ENOENT:
    256             raise e
    257         raise TesseractNotFoundError()
~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout)
    250         cmd_args.append(extension)
    251 
--> 252     try:
    253         proc = subprocess.Popen(cmd_args, **subprocess_args())
    254     except OSError as e:
~\anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    856                             encoding=encoding, errors=errors)
    857 
--> 858             self._execute_child(args, executable, preexec_fn, close_fds,
    859                                 pass_fds, cwd, env,
    860                                 startupinfo, creationflags, shell,
~\anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1309             # Start the process
   1310             try:
-> 1311                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1312                                          # no special security
   1313                                          None, None,
OSError: [WinError 740] The requested operation requires elevation

Any idea on how to overcome this error. Please help me to rectify it

  1. I have downloaded .exe file from https://github.com/UB-Mannheim/tesseract/wiki and executed it.
  2. tesseract.exe file which is present inside "C:\Program Files\Tesseract-OCR" is set to Run this program as Administrator
  3. pytesseract Version: 0.3.8
  4. I have added "C:\Program Files\Tesseract-OCR" to Environmental Variable
Rent Charter Buses Company
READ ALSO
How to slow down sprite animation while maintaining 60 fps in pygame?

How to slow down sprite animation while maintaining 60 fps in pygame?

I'm trying to create a platformer game, and I want to maintain 60 FPS in it without having the sprite animations move really quicklyI've seen other answers on how to do so using the time module, but I don't really understand how to apply that

146
Iris.data.csv - ValueError: x and y must be the same size

Iris.data.csv - ValueError: x and y must be the same size

I'm trying to run this code on Google colab, I got the ValueError: x and y must be the same size, I've tried multiple ways but none of them worked

140
iPython console in Spyder does not enter in debug

iPython console in Spyder does not enter in debug

I removed and started with a fresh new installation of AnacondaJust after installation I created a custom environment (cust_env) Both the cust_env and the base environment have Python 3

124
Plot the multiple values returned by a function

Plot the multiple values returned by a function

My function returns 2 different values which I want to utilise in 2 different graphs using MatplotlibHow can I achieve it?

111