Python - 未检测到使用 easy_install 安装的包(PIL 1.1.7)
我使用 easy_install 安装了 PIL,但由于某种原因,当我运行使用它的文件时,我得到:
ImportError: No module named PIL
有谁知道为什么会这样?
我认为还值得一提的是,我通过 easy_install 安装了 web.py 并且运行良好。
I installed PIL with easy_install but for some reason when I run a file that uses it, I get:
ImportError: No module named PIL
Does anyone know why this could be?
I think it's also worth mentioning that I installed web.py through easy_install and it's working fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我有同样的问题。对我来说,这看起来像是 PIL easy_install 过程中的一个错误。该库已安装,但您必须在导入中忽略 PIL(又名
import Image
有效),这显然是错误的。要解决此问题,请不要使用 easy_install 来执行安装。下载 tar 包并使用
python setup.py install
进行安装。这会起作用。I have the same problem. To me, it looks like a bug in PIL easy_install process. The library is installed, but you have to leave out PIL from imports (aka
import Image
works), which is obviously wrong.To solve, don't use easy_install to perform the install. Download the tar package and
python setup.py install
it. This will work.也许该文件通过其 shebang 行使用不同的 python?
尝试交互式解释器并执行
import pil
并查看它是否有效,如果有效,则修复文件顶部的 shebang 行 (#!/usr/bin/python
)在问题中可能会有所帮助。Perhaps that file is using a different python via its shebang line?
Try interactive interpreter and do a
import pil
and see if it works, if yes, then fixing the shebang line (#!/usr/bin/python
) on top of file in the question might help.您正在运行的文件是否使用与安装 PIL 相同的 Python 版本?
例如,如果文件使用 python 2.7,但您的系统也有 2.6,并且 PIL 已安装在那里,则可能是问题所在。
使用带有版本号的 easy_install 可能会有所帮助:
因此对于 python 2.7,这将是:
PIL 在与 easy_install 一起使用时也存在一些命名问题,
请参阅:
但即使如此,您仍然应该能够导入 pil,所以我认为这不是问题。
希望这有帮助。
Does the file you are running use the same version of Python that you installed PIL to?
If, for e.g. the file uses python 2.7, but your system also has 2.6, and PIL was installed there, that may be the issue.
Using easy_install with a version number might help:
so for python 2.7, it would be:
PIL also has some issues with naming when used with easy_install,
see:
But even with that you should still be able to import pil so I don't think that is the issue.
Hope this helps.
如果您使用的是 MAC OS,我写了一个关于如何在 MAC OS X 上成功安装 libjpeg、PIL 和图像的小教程
希望这会有所帮助。
Libjpeg、PIL、雪豹
if you're using MAC OS, I have written a little tutorial on how to install libjpeg, PIL and image successfully on MAC OS X
Hope this helps.
Libjpeg, PIL, Snow leopard
安装 mac os Lion 后,我在配置 PIL 时遇到了同样的问题。
这篇文章使用 virtualenv 或 buildout 安装 PIL 的问题 显示使用固定版本链接安装的指令。
问候,
在
I had the same problem configuring PIL after installing mac os Lion.
This post The problem with installing PIL using virtualenv or buildout shows the directives to install using a link with a fixed version.
Regards,
AT