Python 导入错误:没有名为 Image 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21456964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 22:53:30  来源:igfitidea点击:

ImportError: No module named Image

pythonmacospython-imaging-library

提问by mihalios

I have also tried

我也试过

from PIL import Image

but it gives me ImportError: No module named PIL.

但它给了我 ImportError: No module named PIL。

I have installed PIL successfully using

我已经成功安装了 PIL

pip install pil

and I've also installed xcode command line tools. Nothing seem to work.

我还安装了 xcode 命令行工具。似乎没有任何效果。

Details:

详情

Mac OS X 10.9

Mac OS X 10.9

Python 2.7.6

蟒蛇 2.7.6

python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python

python是/Library/Frameworks/Python.framework/Versions/2.7/bin/python

python is /usr/bin/python

python是/usr/bin/python

python is /usr/local/bin/python

python是/usr/local/bin/python

Name: PIL

名称: PIL

Version: 1.1.7

版本:1.1.7

Location: /usr/local/lib/python2.7/site-packages/PIL

位置:/usr/local/lib/python2.7/site-packages/PIL

采纳答案by Martijn Pieters

The PIL distribution is mispackaged for egg installation.

PIL 发行版被错误地打包用于 Egg 安装。

Install Pillowinstead, the friendly PIL fork.

改为安装Pillow,友好的 PIL 叉。

回答by qubodup

On a system with both Python 2 and 3 installed and with pip2-installed Pillow failing to provide Image, it is possible to install PIL for Python 2 in a way that will solve ImportError: No module named Image:

在安装了 Python 2 和 3 并且pip2安装 Pillow 未能提供的系统上Image,可以通过以下方式为 Python 2 安装 PIL ImportError: No module named Image

easy_install-2.7 --user PIL

or

或者

sudo easy_install-2.7 PIL