image_to_stringはMacでは機能しません
-
21-12-2019 - |
質問
私はPytesserのこの例に従うことを試みています(リンク)Mac Maverick。
>>> 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
.
しかし、私は私がするべきことを理解していません。FileTestestは同じフォルダ内にあるスクリプトを実行しています。これを修正する方法?
更新:
を試してみるとき
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ライブラリをインストールしましたが、システムレベルでインストールしていませんでした。だから私の問題を解決します。あなたのものはどうですか?
これによって気を取られているかもしれないと思います:
警告:MacportsやFinkがインストールされているように見えます。ソフトウェア 他のパッケージマネージャーとともにインストールされた問題は既知の問題を引き起こします ホームブレイン。式が構築できない場合は、MacPorts / Finkをアンインストールして試してください。 再び
答えが醸造された応答に既に提供されていたことに気づいた:
Tesseractができる前にlibtiff libpng jpegを醸造する必要があります インストールされています。
だから:
brew link libtiff
brew link libpng
brew link jpeg
.
それから:
brew install tesseract
.
最終的に:
:)
. 所属していません StackOverflow