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

混江龙づ霸主 提交于 2019-11-30 03:58:06

问题


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.


回答1:


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.




回答2:


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.




回答3:


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:

easy_install-X.X pil

so for python 2.7, it would be:

easy_install-2.7 pil

PIL also has some issues with naming when used with easy_install, see:

  1. http://www.gossamer-threads.com/lists/python/dev/778318
  2. The problem with installing PIL using virtualenv or buildout

But even with that you should still be able to import pil so I don't think that is the issue.

Hope this helps.




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/5085229/python-package-installed-with-easy-install-is-not-being-detected-pil-1-1-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!