【问题标题】:Failed to import a module导入模块失败
【发布时间】:2019-04-28 12:29:30
【问题描述】:

我尝试使用 ImageGrab(open-cv 功能)

操作系统:lubuntu

首先,我做到了:sudo apt-get install python-opencv。 安装成功。 然后我尝试做:from PIL import ImageGrab。但此时我得到了以下 ImportError:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/user/lib/python2.7/dist-packages/PIL/ImageGrab.py", line 26, in <module> import _grabscreen
ImportError: No module named _grabscreen

我哪里错了?

【问题讨论】:

  • 看起来缺少依赖项。 open-cv 是否支持 py2.7? See this question
  • 看来需要安装 Pillow 模块
  • 您需要先安装 Pillow,然后才能从中导入。类似pip install pillow
  • @jhomr 我做了,但同样的错误。
  • @MarkSetchell 我做了,同样的错误

标签: python python-2.7 opencv ubuntu python-imaging-library


【解决方案1】:

很遗憾 - ImageGrab 仅适用于 Windows

替代方案:pyscreenshot

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-03
    • 2020-03-30
    • 2019-03-30
    • 2021-09-24
    相关资源
    最近更新 更多