【问题标题】:Trouble installing tesseract-ocr package - ''compile failed with error code 1 in /tmp/pip_build_root/tesseract-ocr''安装 tesseract-ocr 包时遇到问题 - “编译失败,在 /tmp/pip_build_root/tesseract-ocr 中出现错误代码 1”
【发布时间】:2023-03-28 15:57:02
【问题描述】:

尝试安装 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。有人对如何解决这个问题有任何想法吗?

【问题讨论】:

    标签: python python-tesseract


    【解决方案1】:

    提供的链接仅提及使用 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/ 不再托管 Tesseract-OCR,因为项目已移至 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/ 上找到安装程序。当前的稳定版本应该包含所有语言。

    【讨论】:

      猜你喜欢
      • 2016-05-01
      • 2018-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多