简体   繁体   English

Snow Leopard,Django和PIL的问题

[英]Problems with Snow Leopard, Django & PIL

I am having some trouble getting Django & PIL work properly since upgrading to Snow Leopard. 自升级到Snow Leopard以来,我在使Django和PIL正常工作方面遇到了一些麻烦。

I have installed freetype, libjpeg and then PIL, which tells me: 我已经安装了freetype,libjpeg和PIL,它告诉我:

--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok

but when I try to upload a jpeg through the django admin interface I get: 但是当我尝试通过django管理界面上传jpeg时,我得到:

Upload a valid image. 上传有效图片。 The file you uploaded was either not an image or a corrupted image. 您上传的文件不是图像或损坏的图像。

It works fine with PNG files. 它适用于PNG文件。

Any Ideas? 有任何想法吗?

Cato 卡托

I had the same experience with Leopard 10.5.x Here is what I did to fix it, (may not work for you). 我对Leopard 10.5.x有过相同的体验。以下是我所做的修复,(可能不适合你)。

  1. Go to your PIL working folder (where you unzipped PIL) cd to your build folder cd to your lib.macosx-10.* folder (specific to your os) remove *.so cd back to your PIL build folder (I logged in as su for this, but you can sudo these if you like) 转到你的PIL工作文件夹(在那里你解压缩PIL)cd到你的构建文件夹cd到你的lib.macosx-10。*文件夹(特定于你的os)删除* .so cd回到你的PIL构建文件夹(我登录为su为此,但你可以sudo这些,如果你喜欢)
  2. python setup.py clean python setup.py清理
  3. python setup.py build python setup.py构建
  4. python setup.py install python setup.py安装

This rebuilds PIL clean. 这样可以重建PIL。 The reason your jpeg reports ok, is that it just looks for the existence of the jpeg lib files, but not the dependency that happens from a clean build and install of PIL. 你的jpeg报告正常的原因是它只是查找jpeg lib文件的存在,而不是从干净的构建和安装PIL发生的依赖。

Hope this solves your problem, mine was more likely related to the order of installation but maybe it will help... 希望这能解决你的问题,我的更可能与安装顺序有关,但也许会有所帮助......

  • Ken

As a follow up to Ken's response, I had the same problem with Snow Leopard 10.6.x which was caused by installing PIL before libjpeg. 作为Ken的回应的后续,我在Snow Leopard 10.6.x中遇到了同样的问题,这是由于在libjpeg之前安装PIL引起的。 After installing libjpeg, I reinstalled PIL by doing the following. 安装libjpeg后,我通过执行以下操作重新安装了PIL。

  1. cd to PIL working folder cd到PIL工作文件夹
  2. python setup.py clean python setup.py清理
  3. python setup.py build_ext -i <-- This rebuilds PIL python setup.py build_ext -i < - 这会重建PIL
  4. python selftest.py - Run the selftest to confirm PIL is installed ok python selftest.py - 运行selftest以确认PIL安装正常
  5. python setup.py install python setup.py安装

I ran into a similar issue while on Ubuntu 8.04. 在Ubuntu 8.04上我遇到了类似的问题。 I was able to get myself out of it by simply re-issuing my PIL install (via pip): 只需重新发布我的PIL安装(通过pip),我就可以摆脱它:

pip install PIL --upgrade

Not sure what the issue was but I suspect it's similar to what others here reported. 不知道问题是什么,但我怀疑它与其他人报道的相似。

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

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