从源构建 tesseract 时出错

从源构建 tesseract 时出错

我在尝试构建 tesseract 时遇到了错误。从日志输出来看,我怀疑是某些 python2 代码导致了问题。我的系统 python 是 3.7。不知道如何解决,任何提示都值得赞赏。

环境:Ubuntu 16.4 lts

重现步骤:(工作目录是tessearact 克隆的git repo)

make clean
git pull
./autogen.sh
./configure --enable-debug
make

回溯的相关部分:

make[2]: Entering directory '/home/neil/Documents/tesseract/tesseract/doc'
asciidoc -b docbook -d manpage -o - combine_lang_model.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'combine_lang_model.1' failed
make[2]: [combine_lang_model.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - combine_tessdata.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'combine_tessdata.1' failed
make[2]: [combine_tessdata.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - dawg2wordlist.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'dawg2wordlist.1' failed
make[2]: [dawg2wordlist.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - lstmeval.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'lstmeval.1' failed
make[2]: [lstmeval.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - lstmtraining.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'lstmtraining.1' failed
make[2]: [lstmtraining.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - merge_unicharsets.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'merge_unicharsets.1' failed
make[2]: [merge_unicharsets.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - set_unicharset_properties.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'set_unicharset_properties.1' failed
make[2]: [set_unicharset_properties.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - tesseract.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'tesseract.1' failed
make[2]: [tesseract.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - text2image.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'text2image.1' failed
make[2]: [text2image.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - unicharambigs.5.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'unicharambigs.5' failed
make[2]: [unicharambigs.5] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - unicharset_extractor.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'unicharset_extractor.1' failed
make[2]: [unicharset_extractor.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - wordlist2dawg.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'wordlist2dawg.1' failed
make[2]: [wordlist2dawg.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - ambiguous_words.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'ambiguous_words.1' failed
make[2]: [ambiguous_words.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - classifier_tester.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'classifier_tester.1' failed
make[2]: [classifier_tester.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - cntraining.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'cntraining.1' failed
make[2]: [cntraining.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - mftraining.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'mftraining.1' failed
make[2]: [mftraining.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - shapeclustering.1.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'shapeclustering.1' failed
make[2]: [shapeclustering.1] Error 6 (ignored)
asciidoc -b docbook -d manpage -o - unicharset.5.asc | \
xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
  File "/usr/bin/asciidoc", line 101
    except KeyError, k: raise AttributeError, k
                   ^
SyntaxError: invalid syntax
-:1: parser error : Document is empty
unable to parse -
Makefile:627: recipe for target 'unicharset.5' failed
make[2]: [unicharset.5] Error 6 (ignored)
make[2]: Leaving directory '/home/neil/Documents/tesseract/tesseract/doc'
Making all in unittest
make[2]: Entering directory '/home/neil/Documents/tesseract/tesseract/unittest'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/neil/Documents/tesseract/tesseract/unittest'
make[1]: Leaving directory '/home/neil/Documents/tesseract/tesseract'

答案1

该代码似乎最初是为 Python 2 编写的。

except KeyError, k

很明显。您必须使用 Python 2 而不是 Python 3 来进行构建(我强烈不推荐这样做)。

更好的选择是找到相应的 Python 3 代码,或者2to3在 Python 文件上运行(同样,不能保证能工作)。

ETA:我注意到罪魁祸首是asciidoc。你必须使用Python 3 版本的 asciidoc

相关内容