来自PIL库的fcgi进程中的Python ctypes MemoryError [英] Python ctypes MemoryError in fcgi process from PIL library

查看:180
本文介绍了来自PIL库的fcgi进程中的Python ctypes MemoryError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to run Django on shared hosting (Bluehost). I'm using functionality that requires PIL. PIL imports and works from an interactive shell, but in my fcgi process it crashes with a MemoryError at from PIL import image. Any help on why it might be failing inside fcgi would be much appreciated.

__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")


推荐答案

我暂时修复了错误评论这个文件的最后一行 $ HOME / lib / python2.7 / ctypes / __ init __。py 就像 #CFUNCTYPE(c_int)(lambda :无)

I have temporarily fixed that error commenting the last line in this file $HOME/lib/python2.7/ctypes/__init__.py that is something like #CFUNCTYPE(c_int)(lambda: None).

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

That's work for me, but i don't know what exactly the problem is.

更新

在python 2.7.3中,行号是:279不最后一个如上所述。

In python 2.7.3 the line number is :279 not the last as I said above.

更新2
由于行可能会在次要版本之间变化,您应该查找一个块的代码看起来像这样:

UPDATE 2 Since the line may vary between minor versions, you should look for a chunk of code that looks something like this:

# 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)

这篇关于来自PIL库的fcgi进程中的Python ctypes MemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆