Search code examples
pythonpycharmtesseractpython-tesseract

Unable to Execute Tesseract command from python


I am trying to execute "tesseract abc.tif abc.txt" from python code as

subprocess.call(["tesseract abc.tif abc.txt"], shell=True, stderr=subprocess.PIPE)

but its showing '"tesseract abc.tif abc.txt"' is not recognized as an internal or external command, operable program or batch file.

subprocess.call(["tesseract"], shell=True, stderr=subprocess.PIPE)

It is executing the above command without any errors. 'tesseract abc.tif abc.txt' I am able to execute from command prompt externally. Only that command unable to execute from python.I am using PYCHARM IDE


Solution

  • I guess, you need to use:

    subprocess.call(["tesseract", "abc.tif", "abc.txt"])
    

    Or, you can use simply:

    import os
    os.system("tesseract abc.tif abc.txt")