For Each ws In ActiveWorkbook.Worksheets
Call BuscarImagemTavares (ws.cells(1,2).value)
Next ws
我尝试制作一个简单的OCR程序,但每当我运行它时,我都会收到以下错误。我甚至卸载了pytesser3并重新安装它但没有任何改变。我做错了什么?
import pytesser3
import Image
a = Image.open("C:\\Users\\dell\\Desktop\\test.png")
b = pytesser3.image_to_string(a)
print(b)
这是test.png: https://i.stack.imgur.com/NBjbc.png
Traceback (most recent call last):
File "C:/Users/dell/Desktop/crossword.py", line 4, in <module>
b = pytesser3.image_to_string(a)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site- packages\pytesser3\__init__.py", line 30, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site- packages\pytesser3\__init__.py", line 20, in call_tesseract
proc = subprocess.Popen(args)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified:
我做了你说的话,但现在我有一个不同的错误:
import pytesser3
import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python36-32\\Lib\\site-packages\\pytesseract'
a = Image.open("C:\\Users\\dell\\Desktop\\test.png")
b = pytesseract.image_to_string(a)
print(b)
答案 0 :(得分:0)
您必须声明pytesseract路径:
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-
OCR/tesseract'
答案 1 :(得分:0)
在pytesser3模块中打开“ init .py”文件。路径类似于“ c:\ .... \ Python \ site-packages \ pytesser3”或“ c:\ .... \ Python \ Lib \ site-packages \ pytesser3”内部。
然后将“ tesseract_exe_name =”的变量值修改为您的pytesseract路径,就像“ C:\ .... \ Python \ Lib \ site-packages \ pytesseract”或“ c:\ .... \ Python \ site-packages \ pytesseract“
它将解决问题。