【问题标题】:Error:ModuleNotFoundError: No module named 'Image'错误:ModuleNotFoundError:没有名为“图像”的模块
【发布时间】:2018-08-14 00:25:24
【问题描述】:

我收到以下错误:

ModuleNotFoundError: 没有名为“图像”的模块

在为 OCR 运行以下脚本时:

import Image
from tesseract import image_to_string


print(image_to_string(Image.open('marlboro.png'), lang='eng'))

我通过 Anaconda 使用 Spider 并安装了 Pillow。

【问题讨论】:

  • 当我遇到这个问题时,我重新安装了 pytesseract 并且它工作正常。有时就这么简单。

标签: python image image-processing ocr


【解决方案1】:

查看docs,您可以在其中看到一些基本示例。简而言之:您需要指定要从PIL 导入Image

from PIL import Image

【讨论】:

  • 感谢我将其更改为,它删除了以前的错误,但弹出了一个新错误 - from PIL import Image from pytesseract import image_to_string print(image_to_string(Image.open('marlboro.png')))但是我现在遇到了一个新错误-
【解决方案2】:

你应该使用 pip 安装pytesseract(另见guide):

pip install pytesseract

然后:

from PIL import Image
from pytesseract import image_to_string

print(image_to_string(Image.open('marlboro.png'), lang='eng'))

或者使用python跨平台模块tesseract:

pip install tesseract

并按照您的问题使用它:

from PIL import Image
from tesseract import image_to_string

print(image_to_string(Image.open('marlboro.png'), lang='eng'))

【讨论】:

  • 我现在收到以下错误 - 文件“C:\ProgramData\Anaconda3\lib\subprocess.py”,第 997 行,在 _execute_child startupinfo) PermissionError: [WinError 5] Access is denied跨度>
  • 你安装了tesseract吗?
  • 尝试以管理员身份运行 IDE
  • 不幸的是,它是我的办公室笔记本电脑,我们没有可用的管理员权限
  • 因此您没有 Anaconda 文件的权限
猜你喜欢
  • 2020-07-30
  • 2022-01-13
  • 2020-01-01
  • 2019-03-09
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多