Python从PIL库中ccpes fcgi进程中的MemoryError

Pet*_*ter 11 python django fastcgi python-imaging-library

我正在尝试在共享主机(Bluehost)上运行Django.我正在使用需要PIL的功能.PIL从交互式shell导入和工作,但是在我的fcgi进程中,它从PIL导入映像中的MemoryError崩溃.任何有关为什么它可能在fcgi内失败的帮助将非常感激.

__Environment Info__:  
Python2.7

Local installs of libjpg, zlib, freetype, and lcms

Virtualenv:  
Django 1.3, PIL, flup, etc.

__Stack Trace__:  

    File ".../feincms_thumbnail.py", line 3, in <module>  
        from PIL import Image

    File ".../PIL/Image.py", line 45, in <module>  
        \__import__("FixTk")

    File ".../python2.7/lib-tk/FixTk.py", line 15, in <module>  
        import ctypes

    File ".../python2.7/ctypes/__init__.py", line 549, in <module>  
        CFUNCTYPE(c_int)(lambda: None)

__.fcgi__:  

<!-- language: python -->
    # setup paths
    # set DJANGO_SETTINGS_MODULE in os.environ  

    from django.core.servers.fastcgi import runfastcgi  
    runfastcgi(method="threaded", daemonize="false")
Run Code Online (Sandbox Code Playgroud)

eos*_*s87 23

我暂时修复了错误,注释了这个文件$HOME/lib/python2.7/ctypes/__init__.py中的最后一行#CFUNCTYPE(c_int)(lambda: None).

这对我有用,但我不知道究竟是什么问题.

UPDATE

在python 2.7.3中,行号是:279不是我上面说的最后一行.

更新2 由于次要版本之间的行可能不同,您应该查找一段看起来像这样的代码:

# XXX for whatever reasons, creating the first instance of a callback
# function is needed for the unittests on Win64 to succeed.  This MAY
# be a compiler bug, since the problem occurs only when _ctypes is
# compiled with the MS SDK compiler.  Or an uninitialized variable?
CFUNCTYPE(c_int)(lambda: None)
Run Code Online (Sandbox Code Playgroud)