Error invoking Python method

Hi @Nalini ,

It’s showing some error with the device loading… Don’t know what exactly it is.

Previously, when i tried to use tessaract OCR in my code, It asked me to involve the application exe file. May be you need to include the driver you want to use in the code itself.

Here is my code which I’m using (Just for your reference) :slight_smile:

try:
from PIL import Image
except ImportError:
import Image
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r"C:\Users\hamadasi\AppData\Local\Tesseract-OCR\tesseract.exe"

filename = ‘D:\Python screenshot\Deepfieldglass.png’

def ocr_core(filename = None):
if filename is None:
filename = ‘D:\Python screenshot\Deepfieldglass.png’
return “file name is null”
text = pytesseract.image_to_string(Image.open(filename)) # We’ll use Pillow’s Image class to open the image and pytesseract to detect the string in the image
textfile = open(r"D:\UiPath files\Time sheets\Attachments\Deepfieldglass.txt",“w+”)
textfile.write(text)
#return text.encode(“utf-8”)
return “Successful”

print(ocr_core(filename))