Occasional ctypes error importing numpy from mod_wsgi django app

前端 未结 2 482
孤城傲影
孤城傲影 2020-12-06 23:14

Here\'s the setup:

  • Django (1.2) app on mod_wsgi that imports ctypes
  • Python 2.6.5
  • Apache 2.2.3
  • SELinux disabled
  • RedHat EL 5
相关标签:
2条回答
  • 2020-12-06 23:51

    Consider turning SELinux off. It should solve the problem.

    0 讨论(0)
  • 2020-12-06 23:57

    I've run into this bug too. In my case it occurs when I exec a Python script from within a PHP script running under Apache on a 64-bit Linux system. [The Python code being run is the front-end to a pypy sandbox.] The same bit of code works fine on a 32-bit system and even works fine when the PHP script is executed directly from the command line. My "fix" has been simply to comment out that line "CFUNCTYPE(c_int)(lambda: None)" in ctypes/init.py. It's the last line of the file and is preceded by the following comment, showing that the programmer doesn't understand what's going on, either!

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

    Clearly there's a deeper problem somewhere in cpython, but the fix works for me.

    0 讨论(0)
提交回复
热议问题