【问题标题】:Running pytesseract in Sagemaker Jupyter notebook在 Sagemaker Jupyter notebook 中运行 pytesseract
【发布时间】:2022-12-28 21:36:02
【问题描述】:

我想在我的 Sagemaker Jupyter 笔记本中使用 pytesseract。

我正在关注 tutorial 安装 pytesseract。运行 pip install 后:

!pip install pytesseract
Looking in indexes: https://pypi.org/simple, https://pip.repos.neuron.amazonaws.com
Requirement already satisfied: pytesseract in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (0.3.10)
Requirement already satisfied: Pillow>=8.0.0 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from pytesseract) (9.0.1)
Requirement already satisfied: packaging>=21.3 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from pytesseract) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from packaging>=21.3->pytesseract) (3.0.6)

该教程指示我应该将 tesseract 可执行文件添加到我的路径但是我不知道 pip 在哪里安装这个可执行文件?

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'

如果我尝试在没有这个的情况下运行 pytesseract,我会收到一条错误消息:

from PIL import Image

import pytesseract

print(pytesseract.image_to_string(Image.open(testimage)))

结果是:


~/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/pytesseract/pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout)
    258             raise
    259         else:
--> 260             raise TesseractNotFoundError()
    261 
    262     with timeout_manager(proc, timeout) as error_string:

TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.

我能够在这里找到 pytesseract 安装:

/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/pytesseract

但是,当我使用该位置更新 tesseract_cmd 并调用相同的代码时,我得到:

PermissionError: [Errno 13] Permission denied: '/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/pytesseract'

我的问题与此 question 不同(但相关),当我链接到 tesseract 二进制文件时,我收到权限被拒绝的错误。

【问题讨论】:

  • 您是否在 Sagemaker Jupyter 笔记本中安装了 tesseract 二进制文件?
  • 我已经审查了那个问题,他们没有遇到与我相同的权限被拒绝错误
  • 好的。 tesseract_cmd 与 pip 包无关。你把路径放错了。它需要 tesseract 二进制文件。再次检查此错误。 TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
  • 在笔记本中尝试!cat /etc/os-release 命令。告诉我结果。

标签: python jupyter-notebook tesseract python-tesseract


【解决方案1】:

我有同样的问题 你找到这个问题的解决方案了吗

【讨论】:

    猜你喜欢
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-24
    • 2020-06-02
    • 2016-11-02
    • 2018-09-26
    相关资源
    最近更新 更多