安装 tesseract-ocr 包时遇到问题 - ''compile failed with error code 1 in /tmp/pip_build_root/tesseract-ocr''

Trouble installing tesseract-ocr package - ''compile failed with error code 1 in /tmp/pip_build_root/tesseract-ocr''

尝试安装与 pytesseract 一起使用的 tesseract-ocr 包,运行 遇到一个奇怪的问题。使用 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。有没有人知道如何解决这个问题?

提供的link只提到使用Pip安装pytesseract,没有提到Tesseract-OCR。

如前所述,您还需要 Python 成像库 (PIL),如果您的系统中未安装它,您可以通过 sudo pip install pillow.

使用 Pillow

Tesseract-OCR 未与使用 sudo pip install tesseract-ocr 的 Pip 一起安装,因为它不是像 pytesseract 这样的 Python 模块。据我所知,Tesseract-OCR 主要是用 C++ 编写的。

给出link,http://code.google.com/p/tesseract-ocr/, is no longer hosting Tesseract-OCR as the project has been moved to https://github.com/tesseract-ocr/tesseract.

可以在 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/ 上找到安装程序。当前的稳定版本应该包含所有语言。