首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Pytesser3中找不到错误

在Pytesser3中找不到错误
EN

Stack Overflow用户
提问于 2017-07-25 13:34:44
回答 2查看 289关注 0票数 1
代码语言:javascript
复制
import pytesser3
import Image
a = Image.open("C:\\Users\\dell\\Desktop\\test.png") 
b = pytesser3.image_to_string(a)
print(b)

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

代码语言:javascript
复制
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

代码语言:javascript
复制
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)

我照你说的做了,但现在我犯了一个不同的错误:

代码语言:javascript
复制
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.
EN

回答 2

Stack Overflow用户

发布于 2017-07-25 13:39:53

您必须声明pytesseract路径:

代码语言:javascript
复制
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-
OCR/tesseract'
票数 0
EN

Stack Overflow用户

发布于 2019-04-26 04:45:23

模块中打开“.py”文件。路径应该是“c:.\Python\site-packages\pytesser3 3”,或者在“c:.Python\Lib\site-packages\pytesser3 3”中。

并将"tesseract_exe_name =“的变量值修改为pytesseract路径,该路径类似于”C:.\Python\Lib\site-packages\pytesseract“或”c:.\Python packages\pytesseract“

它将解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45304963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档