CentOS&Python&Django安装PIL

问题描述:使用Django搭建一个网站时候,涉及到图片内容的,model有ImageField可用,但是在同步数据库的时候,报错如下

CommandError: One or more models did not validate:
PhotoGallery.photo: "image": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .

环境工具:CentOS6.3  Python2.6 Django1.5

解决过程:1. 根据报错提示安装python类库PIL,下载地址 http://www.pythonware.com/products/pil/。点击Python Imaging Library 1.1.7 Source Kit 下载Imaging-1.1.7.tar.tar。安装报错如下

_imaging.c: In function 釯magingError_Clear?
_imaging.c:338: warning: implicit declaration of function 釶yErr_Clear?
_imaging.c: At top level:

                  2. 根据提示和网上指导安装libjpeg-devel和python-devel

                       yum install libjpeg-devel

                       yum install python-devel

                  3. 使用./manage.py syncdb 生成带ImageField字段的表OK(其实django的ImageField不是在数据库面直接存储blob类型的媒体资源,也是在数据库的列里面存储资源路径,只不过将资源路径和文件的对应封装起来,由django自己来处理,开发人员就不用太操心了)

猜你喜欢

转载自834945712.iteye.com/blog/1861073
今日推荐