2014-01-10 42 views
6

我試圖在Mac Maverick中遵循pytesser(link)的這個例子。image_to_string在Mac無法正常工作

>>> 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在我運行腳本的同一個文件夾中。如何解決這個問題?

UPDATE:

當我嘗試

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 
+0

它看起來像你的腳本有一個啓動過程中的問題......它看起來像https://code.google.com/p/pytesser/wiki/描述了同樣的問題自述文件 發行版隨附Windows可執行文件,在Mac上無法使用。正如那裏提到的Linux人員,您可能需要提供一個tessact可執行文件。 – Luis

+0

明白了。但我可以這樣做嗎? –

+0

我確定它是可行的,但我不知道詳細信息:應爲tessact用戶標記問題。 – Luis

回答

8

其實我有同樣的錯誤,你,這是我發現這個職位。我也解決了我的問題,因爲你把它給了我!

我看到:

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 

Then:

brew install tesseract 

最後:

:) 
+0

它爲我謝謝! Mac OS High Sierra,python 3 =) –

相關問題