【问题标题】:Not Found Error in Pytesser3在 Pytesser3 中未找到错误
【发布时间】:2017-07-25 13:34:44
【问题描述】:
import pytesser3
import Image
a = Image.open("C:\\Users\\dell\\Desktop\\test.png") 
b = pytesser3.image_to_string(a)
print(b)

我尝试制作一个简单的 OCR 程序,但每次运行时都会出现以下错误。我什至卸载了 pytesser3 并重新安装了它,但没有任何改变。我做错了什么?

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:

这是 test.png: https://i.stack.imgur.com/NBjbc.png


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)

我按照你说的做了,但现在我遇到了另一个错误:

Traceback (most recent call last):
  File "C:/Users/dell/Desktop/crossword.py", line 6, in <module>
b = pytesseract.image_to_string(a)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  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)
PermissionError: [WinError 5] Access denied.

【问题讨论】:

    标签: python python-3.x ocr pytesser


    【解决方案1】:

    您必须声明 pytesseract 路径:

    import pytesseract
    pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-
    OCR/tesseract'
    

    【讨论】:

      【解决方案2】:

      在 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"

      它会解决问题。

      【讨论】:

        猜你喜欢
        • 2017-10-15
        • 2012-10-26
        • 1970-01-01
        • 1970-01-01
        • 2014-02-15
        • 2019-01-08
        • 2012-05-26
        • 2018-11-13
        • 2023-03-11
        相关资源
        最近更新 更多