2017-05-26 71 views
-1

所以,我有这个验证码,我需要从中提取文本。枕头(PIL)显示“FileNotFoundError”

我一直在使用枕头来完成这个工作,我尝试了许多其他库直接从github和他们都没有工作。随着枕头,我得到这个错误:

Traceback (most recent call last): 
    File "F:/Competitions/Donations/Scrapping.py", line 111, in <module> 
    Scrapping() 
    File "F:/Competitions/Donations/Scrapping.py", line 57, in __init__ 
    myText = image_to_string(Image.open(filePath), config='-psm 10') 
    File "C:\Users\User Name\AppData\Roaming\Python\Python35\site-packages\pytesseract\pytesseract.py", line  161, in image_to_string 
config=config) 
    File "C:\Users\User Name\AppData\Roaming\Python\Python35\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract 
    stderr=subprocess.PIPE) 
    File "C:\Pythons\Python3.5\lib\subprocess.py", line 947, in __init__ 
    restore_signals, start_new_session) 
    File "C:\Pythons\Python3.5\lib\subprocess.py", line 1224, in _execute_child 
    startupinfo) 
FileNotFoundError: [WinError 2] The system cannot find the file specified 

这是一个基于image_to_string方法的错误,我不能左右我的头来解决这个问题。对此有何建议?

这是我使用的代码:

myText = image_to_string(Image.open(filePath)) 

filePath是图片路径。

P.S:验证码图片:http://imgur.com/dRmna1z

+1

它只会出现那个'filePath'不正确,或以其他方式不存在的。 – Evert

+0

错误消息说您的代码是'myText = image_to_string(Image.open(filePath),config =' - psm 10')' –

+0

尝试了2种方式。我发布的一个和另一个命令来检查它错误的地方。现在这个错误已经修复了 – Xonshiz

回答

1

看来你没有安装tesseract或您PATH

the directions你需要能够从命令行调用tesseract

您得到的实际错误与PILPillow无关(注意您的堆栈跟踪中没有列出PIL文件)。

实际的错误来源于here子处理出来tesseract

+0

只需双重检查,我就可以从我的命令行启动'tesseract'。这里:http://imgur.com/3Invnix – Xonshiz

+0

好的,现在这个工作。我刚刚关闭了我的IDE,重新运行它,现在它工作。 wth:/ – Xonshiz