2017-05-26 67 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