image_to_string在Mac中不起作用 [英] image_to_string doesn't work in Mac

查看:97
本文介绍了image_to_string在Mac中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在以下示例中使用pytesser(链接) Mac Maverick.

I'm trying to follow this example of pytesser (link) in a Mac Maverick.

>>> from pytesser import *
>>> im = Image.open('phototest.tif')
>>> text = image_to_string(im)

但是,在最后一行中,我收到以下错误消息:

But, in the last line I get this error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pytesser.py", line 31, in image_to_string
    call_tesseract(scratch_image_name, scratch_text_name_root)
  File "pytesser.py", line 21, in call_tesseract
    proc = subprocess.Popen(args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

但是,我不知道该怎么办. phototest文件位于我正在运行脚本的同一文件夹中.该如何解决?

But, I don't understand what I should do. The file phototest is in the same folder I'm running the script. How to fix this?

更新:

当我尝试

brew install tesseract

我收到此错误:

Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: You must `brew link libtiff libpng jpeg' before tesseract can be installed

推荐答案

我实际上和您有相同的错误,这就是我找到此帖子的方式.我也有解决问题的方法,因为您把它给了我!

I actually had the same error as you, which is how I found this post. I also have the solution to my problem, because you gave it to me!

我看到了:

ryan.davis$ python tesseract.py
Traceback (most recent call last):
  File "tesseract.py", line 52, in <module>
    print (image_to_string(big))
  File "/usr/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 161, in image_to_string
    config=config)
  File "/usr/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 94, in run_tesseract
    stderr=subprocess.PIPE)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/local/Cellar/python/2.7.10_2/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

想知道我该怎么做才能解决此问题?正是您尝试的方法:brew install tesseract我已经安装了tesseract python库,但尚未在系统级安装它.这样就解决了我的问题.你呢?

Want to know what I had to do to fix this? Exactly what you tried: brew install tesseract I had installed the tesseract python library, but hadn't installed it at the system level. So that solves my problem. How about yours?

我认为您可能为此而分心:

I think you might have been distracted by this:

警告:看来您已经安装了MacPorts或Fink.软件 与其他程序包管理器一起安装会导致以下已知问题 自制酒.如果公式无法生成,请卸载MacPorts/Fink并尝试 再次.

Warning: It appears you have MacPorts or Fink installed. Software installed with other package managers causes known problems for Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.

没有注意到您的答案已经在Brew响应中提供了:

And not noticed your answer was already provided in the brew response:

您必须先酿造链接libtiff libpng jpeg,然后才能进行tesseract 已安装.

You must brew link libtiff libpng jpeg before tesseract can be installed.

这样做:

brew link libtiff 
brew link libpng 
brew link jpeg

然后:

brew install tesseract

最后:

:)

这篇关于image_to_string在Mac中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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