使用Python映像库(PIL)时出现Django MemoryError

时间:2012-06-30 17:24:27

标签: python django python-imaging-library

添加具有ImageField的表单后,我的网站上出现了MemoryError。代码在我的开发服务器(OS X 10.7.4)上运行正常,但在我的暂存环境(CentOS)中失败。

我有点不愿意使用此处提出的解决方案来解决类似的问题:Python ctypes MemoryError in fcgi process from PIL library。它改变了python本身 - 这似乎对长期维护不利。

我对如何调试这个有点无能为力......请帮助我治愈我的无知......

这是追溯:

Environment:


Request Method: POST
Request URL: http://myschoolzoneapp.eatechinc.com/debug/

Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'accounts',
 'announcements',
 'api',
 'devices',
 'events',
 'menus',
 'organizations',
 'djangorestframework',
 'registration',
 'guardian',
 'south',
 'profiles')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'ischoolhub_project.middleware.ProcessMiddleware')


Traceback:
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/eatech/django/projects/ischoolhub-staging/ischoolhub_project/views.py" in debug
  22.         if form.is_valid():
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in is_valid
  124.         return self.is_bound and not bool(self.errors)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in _get_errors
  115.             self.full_clean()
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in full_clean
  270.         self._clean_fields()
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in _clean_fields
  285.                     value = field.clean(value, initial)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in clean
  535.         return super(FileField, self).clean(data)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in clean
  153.         value = self.to_python(value)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in to_python
  560.             import Image
File "/tmp/egg-cache/PIL-1.1.7-py2.7-linux-i686.egg/Image.py" in <module>
  45.     __import__("FixTk")
File "/usr/local/lib/python2.7/lib-tk/FixTk.py" in <module>
  15.     import ctypes
File "/usr/local/lib/python2.7/ctypes/__init__.py" in <module>
  555. _reset_cache()
File "/usr/local/lib/python2.7/ctypes/__init__.py" in _reset_cache
  279.     CFUNCTYPE(c_int)(lambda: None)

Exception Type: MemoryError at /debug/
Exception Value: 

1 个答案:

答案 0 :(得分:0)

通过在用户标识下运行mod_wsgi来解决https://bugzilla.redhat.com/show_bug.cgi?id=717404问题。