无法安装tesseract-ocr软件包 - ''编译失败,错误代码1在/ tmp / pip_build_root / tesseract-ocr''

时间:2015-11-21 23:29:18

标签: python python-tesseract

尝试安装tesseract-ocr软件包以便与pytesseract一起使用,遇到一个奇怪的问题。使用pip安装其他所有内容,但当我按照指示here尝试sudo pip install tesseract-ocr时,我收到以下错误:

Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/tesseract-ocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zsaPkE-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/tesseract-ocr
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
    return command.main(cmd_args)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)

我感觉回溯导致了UnicodeDecodeError。有没有人对如何解决这个问题有任何想法?

1 个答案:

答案 0 :(得分:4)

提供的链接仅提到使用Pip来安装pytesseract而不是Tesseract-OCR。

如前所述,您还需要Python Imaging Library(PIL),如果您的系统中未安装它,则可以使用sudo pip install pillow来使用Pillow。

Tesseract-OCR没有使用sudo pip install tesseract-ocr的Pip安装,因为它不是像pytesseract这样的Python模块。从我看来,Tesseract-OCR主要是用C ++编写的。

由于项目已移至http://code.google.com/p/tesseract-ocr/,所提供的链接https://github.com/tesseract-ocr/tesseract不再托管Tesseract-OCR。

可以在https://github.com/tesseract-ocr/tesseract/wiki上找到安装说明。

对于Linux使用,sudo apt-get install tesseract-ocrsudo apt-get install tesseract-ocr-all安装所有语言。

对于Mac使用,brew install tesseractbrew install tesseract --all-languages安装所有语言。您需要安装Homebrew,可以在https://brew.sh找到。

对于Windows,可以在https://github.com/tesseract-ocr/tesseract/wiki/Downloads/上找到安装程序。当前的稳定版本应包含所有语言。