【问题标题】:StopIteration: Could not import PIL.Image. The use of `array_to_img` requires PILStopIteration:无法导入 PIL.Image。 `array_to_img`的使用需要PIL
【发布时间】:2018-05-09 22:36:16
【问题描述】:

运行 keras 代码时出现此错误,因此 keras 正在尝试导入

从 PIL 导入图像为 pil_image

我已经安装了枕头,我也可以在我的 python 终端中成功导入它,但是在 jupyter notebook 中它给出了导入错误。

env - aws ec2 实例上的 ubuntu 16,我在 ubuntu 上使用 aws 深度学习 ami

枕头自带conda,我也试过用pip安装

但我可以在 python/ipython shell 中导入它,但不能在 jupyter notebook 中导入。

【问题讨论】:

  • 多写一点你的环境。操作系统、Python、Jupyter 包。如果您有多个 Python 安装。你是如何安装枕头的(也许是在虚拟环境中?)。安装了 PIP (pillow.readthedocs.io/en/3.0.x/installation.html),也许是 conda (anaconda.org/anaconda/pillow)?虽然我记得,“大”Anaconda 包装盒中配有开箱即用的枕头。
  • 已编辑.. 谢谢
  • 我曾经遇到过 Jupyter 的一个错误,它从未指向正确的环境。用户 import sysprint(sys.executable) 查看您的 jupyter 正在运行哪个 python。也许您应该卸载 jupyter 并在正确的环境中通过 conda 安装它。或者直接使用conda install jupyter 将其安装在正确的环境中。

标签: keras jupyter-notebook pillow


【解决方案1】:

所以,jupyter 笔记本上的 jesper 或 opencv 包中似乎包含了枕头/pil,所以我在笔记本的包门户中卸载了 jesper 和 opencv 并安装了枕头。现在一切正常。

【讨论】:

    【解决方案2】:

    我已经安装了 opencv。但我刚刚安装了枕头(保持 opencv),它对我有用。

    【讨论】:

    • 需要的人:命令是pip install --ignore-installed pillow
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    相关资源
    最近更新 更多