Python Pillow 已安装,但在导入时出现“没有名为枕头的模块”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23834663/
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-19 03:29:50  来源:igfitidea点击:

Pillow installed, but getting "no module named pillow" when importing

pythonpippython-imaging-librarypython-import

提问by billrichards

I installed the Pillowpackage with:

我安装了Pillow软件包:

python -m pip install pillow

Got success message (Successfully installed pillow). Closed and re-opened the terminal.

收到成功消息 ( Successfully installed pillow)。关闭并重新打开终端。

But when I try to:

但是当我尝试:

import pillow

I get the error message:

我收到错误消息:

ImportError: No module named pillow

导入错误:没有名为枕头的模块

If python -m pip install pillowis run again, it says

如果python -m pip install pillow再次运行,它会说

Requirement already satisfied (use --upgrade to upgrade): pillow in c:\python27\lib\site-packages

采纳答案by MattDMo

Try using

尝试使用

import PIL

or

或者

from PIL import ...

instead. Pillowis a fork of PIL, the Python Imaging Library, which is no longer maintained. However, to maintain backwards compatibility, the old module name is used.

反而。PillowPILPython Imaging Library 的一个分支,不再维护。但是,为了保持向后兼容性,使用了旧的模块名称。