我在使用Tesseract-OCR和Pytesseract Python包裝器時遇到問題。 我想這個問題可能來自Tesseract本身,而不是來自包裝。 於是,我就在的Tesseract CMD:在Windows上嘗試Tesseract CMD
C:\Users\Thomas\Desktop>tesseract.exe 'blabla.jpg' 'out.txt'
它返回以下行:
Tesseract Open Source OCR Engine v3.05.01 with Leptonica
Error in fopenReadStream: file not found
Error in findFileFormat: image file not found
Error during processing.
我已經做了以下安裝的Tesseract:
- 從那裏安裝:https://github.com/UB-Mannheim/tesseract/wiki
- 將tesseract.exe的路徑添加到PATH環境變量
而且通過我在哪裏運行我的Python代碼的方式,問題:
from PIL import Image
import pytesseract
text = pytesseract.image_to_string(Image.open('blabla.jpg')
print(text)
是:
Traceback (most recent call last):
File "<ipython-input-1-01e77f902509>", line 1, in <module>
runfile('D:/anaconda/projects/OCR/ocr.py', wdir='D:/anaconda/projects/OCR')
File "D:\anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "D:\anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/anaconda/projects/OCR/ocr.py", line 48, in <module>
text = pytesseract.image_to_string(a)
File "D:\anaconda\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "D:\anaconda\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "D:\anaconda\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "D:\anaconda\lib\subprocess.py", line 990, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access refused
運行代碼以管理員身份不解決問題
非常感謝您的幫助!
請閱讀[「我應該怎麼做當有人回答我的問題?」](http://stackoverflow.com/help/someone-answers)。 – thewaywewere