问题
I'm trying to use PIL for a Google App Engine project. I've installed PIL using the installer from pythononmac.org but it doesn't seem to do anything, or at least neither I nor Python can find the files. I'm running Python 2.5.1.
回答1:
The installers found on that page were designed to be used with the python 2.5 installer found there. Note that most of the packages are now out-of-date. The PIL installer uses the site-packages library in the framework used by the 2.5 Python on that page and by the more up-to-date python.org installer: /Library/Frameworks/Python.framework/Versions/2.5
. The Apple-supplied Python 2.5 (/usr/bin/python2.5
in OS X 10.5
) looks for site-packages
in a different location: /Library/Python/2.5
. If you first install the python.org (or the pythonmac.org) 2.5, that python can be invoked by /usr/local/bin/python2.5
and the PIL installer package should work with it.
Unfortunately, installing PIL on OS X is more complicated than many other python packages because of its dependence on third-party libraries not supplied by Apple in OS X. While it is possible to build it on your own, you may be better off using a more up-to-date version of python with PIL from MacPorts, for example (see packages py25-pil
or py26-pil
).
I do not recommend using the symlink trick advocated by some bloggers (for instance, here) as this can end up contaminating the Apple-supplied Python and complicating support of multiple Python versions when you want to upgrade to python 2.6 and/or 3.1.
来源:https://stackoverflow.com/questions/1774825/unable-to-use-pil-after-installing-using-pythononmac-org-package-mac-os-leopard