Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

python - OSError: [WinError 740] The requested operation requires elevation

I am having a simple code which has an image called "try.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
pytesseract.pytesseract.tesseract_cmd=r'tesseract-ocr-setup-4.00.00dev.exe'
img = cv2.imread('try.png')
img= cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img))

But it's giving me an error.

Traceback (most recent call last):
  File "C:/Users/user 1/PycharmProjects/JARVIS/try.py", line 6, in <module>
    print(pytesseract.image_to_string(img))
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsite-packagespytesseractpytesseract.py", line 356, in image_to_string
    return {
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsite-packagespytesseractpytesseract.py", line 359, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsite-packagespytesseractpytesseract.py", line 270, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsite-packagespytesseractpytesseract.py", line 241, in run_tesseract
    raise e
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsite-packagespytesseractpytesseract.py", line 238, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsubprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:Usersuser 1AppDataLocalProgramsPythonPython38-32libsubprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 740] The requested operation requires elevation

Process finished with exit code 1

Any idea on how to over come this error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

tesseract-ocr-setup-4.00.00dev.exe sounds like a setup exe and not the tesseract itself. Check if you have actually installed tesseract and if not launch the exe to install.

For Windows download the latest version from here: https://github.com/UB-Mannheim/tesseract/wiki

If you still get OSError: [WinError 740] The requested operation requires elevation try changing the tesseract executable to run as admin: Right Click tesseract.exe -> Properties -> Compability -> Check Run this program as an administrator -> OK .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...