在Pytesser3中找不到错误

2024-10-02 08:21:14 发布

您现在位置:Python中文网/ 问答频道 /正文

import pytesser3
import Image
a = Image.open("C:\\Users\\dell\\Desktop\\test.png") 
b = pytesser3.image_to_string(a)
print(b)

我试图做一个简单的OCR程序,但每当我运行它,我得到以下错误。我甚至卸载了pytesser3并重新安装了它,但是没有任何改变。我做错什么了?在

^{pr2}$

这是测试.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.

Tags: inpyimageimportpnglocallineusers
2条回答

必须声明pytesseract路径:

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

打开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”

它将解决这个问题。在

相关问题 更多 >

    热门问题