我正在尝试运行此 python 代码,但它不断抛出相同的错误。我在 Windows 机器上使用 pytesseract(在 pycharm 中编码)来扫描图像。我在 cloud9 上做了一个项目,在亚马逊网络服务中大量使用了 pytesseract,一切正常我确信这是一个 Windows 问题。这一切都在 python 2.7 中(这是我在一个更大的项目中调试同样问题的一个小测试程序)
这是我的代码:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
filename = "Z:\Pycharm Projects\IBM-Waldon-master\screenshots\image.png"
print pytesseract.image_to_string(Image.open(filename))
我已经尝试将代码的核心变成一个函数并重新启动我的计算机,但它仍然会抛出这个错误:
Z:\Python27\interpeter\Scripts\python.exe "Z:/Pycharm Projects/IBM-Waldon-
master/testest.py"
Traceback (most recent call last):
File "Z:/Pycharm Projects/IBM-Waldon-master/testest.py", line 9, in <module>
print pytesseract.image_to_string(Image.open(filename))
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 193, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 111, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "Z:\Python27\Lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "Z:\Python27\Lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Process finished with exit code 1