简体   繁体   English

Python - 未使用easy_install安装的软件包(PIL 1.1.7)

[英]Python - package installed with easy_install is not being detected (PIL 1.1.7)

I installed PIL with easy_install but for some reason when I run a file that uses it, I get: 我用easy_install安装了PIL,但出于某种原因,当我运行一个使用它的文件时,我得到:

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. 我认为值得一提的是我通过easy_install安装了web.py并且工作正常。

I have the same problem. 我也有同样的问题。 To me, it looks like a bug in PIL easy_install process. 对我来说,它看起来像是PIL easy_install过程中的一个错误。 The library is installed, but you have to leave out PIL from imports (aka import Image works), which is obviously wrong. 库已安装,但您必须从导入中删除PIL(也就是import Image工作),这显然是错误的。

To solve, don't use easy_install to perform the install. 要解决此问题,请不要使用easy_install来执行安装。 Download the tar package and python setup.py install it. 下载tar包和python setup.py install它。 This will work. 这会奏效。

Perhaps that file is using a different python via its shebang line? 也许那个文件通过它的shebang线使用不同的python? 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. 尝试交互式解释器并进行import pil并查看它是否有效,如果是,则在问题文件顶部修复shebang行( #!/usr/bin/python )可能有所帮助。

Does the file you are running use the same version of Python that you installed PIL to? 您运行的文件是否使用与安装PIL相同的Python版本?

If, for eg the file uses python 2.7, but your system also has 2.6, and PIL was installed there, that may be the issue. 如果,例如文件使用python 2.7,但你的系统也有2.6,并且那里安装了PIL,那可能就是问题所在。

Using easy_install with a version number might help: 将easy_install与版本号一起使用可能会有所帮助:

easy_install-X.X pil

so for python 2.7, it would be: 所以对于python 2.7,它将是:

easy_install-2.7 pil

PIL also has some issues with naming when used with easy_install, see: 与easy_install一起使用时,PIL也存在一些命名问题,请参阅:

  1. http://www.gossamer-threads.com/lists/python/dev/778318 http://www.gossamer-threads.com/lists/python/dev/778318
  2. The problem with installing PIL using virtualenv or buildout 使用virtualenv或buildout安装PIL的问题

But even with that you should still be able to import pil so I don't think that is the issue. 但即便如此,你仍然可以导入pil,所以我不认为这是问题。

Hope this helps. 希望这可以帮助。

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 如果你正在使用MAC OS,我已经写了一些关于如何在MAC OS X上成功安装libjpeg,PIL和图像的教程

Hope this helps. 希望这可以帮助。 Libjpeg, PIL, Snow leopard Libjpeg,PIL,雪豹

I had the same problem configuring PIL after installing mac os Lion. 安装mac os Lion后我遇到了配置PIL的问题。 This post The problem with installing PIL using virtualenv or buildout shows the directives to install using a link with a fixed version. 这篇文章使用virtualenv或buildout安装PIL的问题显示了使用固定版本的链接进行安装的指令。

Regards, AT 此致,AT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM