I need to use ImageField
in my models and PIL seems not to be installed:
>>> from PIL import Image
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named PIL
However I can see python-imaging installed in Synaptic. When I try to easy-install it, I get:
$ sudo easy_install-2.7 PIL
[sudo] password for glide:
Searching for PIL
Reading http://pypi.python.org/simple/PIL/
Reading http://www.pythonware.com/products/pil
Reading http://effbot.org/zone/pil-changes-115.htm
Reading http://effbot.org/downloads/#Imaging
Best match: PIL 1.1.7
Downloading http://effbot.org/media/downloads/PIL-1.1.7.tar.gz
Processing PIL-1.1.7.tar.gz
Running PIL-1.1.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-HvRSQr/PIL-1.1.7/egg-dist-tmp-nDJHmU
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
libImaging/Quant.c: In function ‘rehash_collide’:
libImaging/Quant.c:154: warning: cast to pointer from integer of different size
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.1 (r271:86832, May 2 2011, 14:22:06)
[GCC 4.4.3]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
zip_safe flag not set; analyzing archive contents...
Image: module references __file__
Adding PIL 1.1.7 to easy-install.pth file
Installing pilconvert.py script to /usr/local/bin
Installing pilprint.py script to /usr/local/bin
Installing pildriver.py script to /usr/local/bin
Installing pilfont.py script to /usr/local/bin
Installing pilfile.py script to /usr/local/bin
Installed /usr/local/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-x86_64.egg
Processing dependencies for PIL
Finished processing dependencies for PIL
And this is still not usable. Do I have to do something else to be able to use the ImageField
field type ?
Samuele Mattiuzzo gave me the answer:
have you tried with import Image instead of from PIL import Image? sometimes this solves the issue
Also sometimes this may not work:
pip install pil
Check this out : gcc error trying to install PIL in a Python2.6 virtualenv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With