Error converting Simple Captcha to string using te

2019-02-20 01:06发布

问题:

I want to automate some login processes for a ticketing system. There is a simple captcha at the login screen. I am able to take a partial snapshot of it, but as soon as I send that image to image_to_string() function, there is a error. The error says:

"[Win Error 2] The system cannot find the file specified"

回答1:

The problem here is not that tesseract can't find your image, it's that Windows can't find tesseract.

pytesseract internally runs subprocess.Popen(['tesseract', input_file]), and this throws the error. But if you try subprocess.Popen(['tesseract']), you'll get the exact same error.

If you read the installation instructions you'll see:

You must be able to invoke the tesseract command as tesseract.

And:

If this isn't the case, for example because tesseract isn't in your PATH, you will have to change the "tesseract_cmd" variable at the top of tesseract.py

So you can either add tesseract to your PATH or modify the tesseract_cmd to point directly to your tesseract executable.