gpt4 book ai didi

python - image_to_string 在 Mac 中不起作用

转载 作者:太空狗 更新时间:2023-10-29 22:26:34 25 4
gpt4 key购买 nike

我正在尝试在 Mac Maverick 中遵循这个 pytesser ( link) 的例子。

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

但是,在最后一行我收到了这个错误信息:

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 位于我运行脚本的同一文件夹中。如何解决这个问题?

更新:

当我尝试

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

最佳答案

我实际上和你有同样的错误,这就是我找到这篇文章的方式。我也有解决问题的办法,因为你给了我!

我看到了:

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 库,但没有在系统级别安装它。这样就解决了我的问题。你的呢?

我想你可能已经被这个分心了:

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 响应中提供了:

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

也一样:

brew link libtiff 
brew link libpng
brew link jpeg

然后:

brew install tesseract

最后:

:)

关于python - image_to_string 在 Mac 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21049425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com