导入ctypes模块错误 - RuntimeError: ffi_prep_closure失败,错误码2

0 投票
1 回答
603 浏览
提问于 2025-04-18 12:29

在导入ctype这个Python模块的时候,我遇到了以下错误:

root@root# python

Python 2.7.3 (default, Jul  7 2014, 18:10:53) 
[GCC 4.7.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import ctypes

Traceback (most recent call last):

  File "stdin", line 1, in "module"

  File "/usr/lib32/python2.7/ctypes/__init__.py", line 555, in "module"

    _reset_cache()
  File "/usr/lib32/python2.7/ctypes/__init__.py", line 279, in _reset_cache

    CFUNCTYPE(c_int)(lambda: None)
RuntimeError: ffi_prep_closure failed with 2
>>> 

如果需要更多信息,请告诉我。

谢谢

1 个回答

0

这是因为Python使用的外部函数接口(FFI)来自libffi。

通过以下路径问题可以解决:

https://gcc.gnu.org/viewcvs/gcc/trunk/libffi/src/mips/ffi.c?r1=190696&r2=190695&pathrev=190696

撰写回答