Django MemoryError while Using Python Imaging Library (PIL)



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

我有点不愿意使用这里提出的解决方案来解决看起来像类似的问题:来自 PIL 库的 fcgi 进程中的 Python ctypes MemoryError。 它改变了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: 

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

最新更新