OSError: [Errno 2] 没有这样的文件或目录使用 pytesser [英] OSError: [Errno 2] No such file or directory using pytesser

查看:24
本文介绍了OSError: [Errno 2] 没有这样的文件或目录使用 pytesser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题,我想用pytesser来获取图片的内容.我的操作系统是Mac OS 10.11,我已经安装了PIL、pytesser、tesseract-ocr引擎以及libpng等其他支持库.但是当我运行我的代码时,如下所示,发生错误.

This is my problem, I want to use pytesser to get a picture's contents. My operating system is Mac OS 10.11, and I have already installed PIL, pytesser, tesseract-ocr engine, and other supporting libraries like libpng and so on. But when I run my code, as below, error occurs.

from pytesser import *
import os
image = Image.open('/Users/Grant/Desktop/1.png')
text = image_to_string(image)
print text

接下来是错误信息

Traceback (most recent call last):
File "/Users/Grant/Documents/workspace/image_test/image_test.py",    line 10, in <module>
text = image_to_string(im)
File   "/Users/Grant/Documents/workspace/image_test/pytesser/pytesser.py", line   30, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "/Users/Grant/Documents/workspace/image_test/pytesser/pytesser.py", line 21, in call_tesseract
retcode = subprocess.call(args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

此外,tesseract-ocr 引擎在我的 Mac 上运行良好,我可以在终端中运行它并得到结果.下面是测试图片结果.tesseract 结果

Besides, tesseract-ocr engine runs well on my Mac, I can run it in terminal and get the result. Below is the test picture result. tesseract result

有人可以帮我解答这个问题吗?

Can anyone help me with this question,please?

推荐答案

幸运的是,我解决了这个问题.

Luckily, I solved this one.

首先,我运行命令

pip install pytesseract

安装软件包.

但是我收到了使用 pytesser 没有这样的文件或目录"的错误消息.

But I get the error message of 'No such file or directory using pytesser'.

然后我阅读了此链接:image_to_string 在 Mac 中不起作用因此,只需运行以下脚本:

Then I read this link: image_to_string doesn't work in Mac So, just run the following script:

brew link libtiff 
brew link libpng 
brew link jpeg
brew install tesseract

为我工作~

这篇关于OSError: [Errno 2] 没有这样的文件或目录使用 pytesser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆