我制作了一个类似于here和here的c ++类的python包装。但是生成的python包装器仅在python2中可用,而在python3中给出以下错误:
dynamic module does not define module export function (PyInit_...)
我的 setup.py 如下所示:
## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
setup_args = generate_distutils_setup(
packages=['hw_interface_pkg'],
package_dir={'': 'src'},
requires=['std_msgs', 'rospy'],
language_level="3",
compiler_directives={'language_level' : "3"}
)
setup(**setup_args)
在this thread之后,我尝试将language_level = "3"
或compiler_directives={'language_level' : "3"}
添加到上述 setup_args 中,但没有一个能够解决问题。
我的pyx文件也看起来像:
cdef extern from "remote_hw.h":
cdef cppclass ROBOTHardwareInterface:
ROBOTHardwareInterface() except +
double c_fibonacci(double n);
cdef class PyHWInterface:
cdef ROBOTHardwareInterface c_obj
def __cinit__(self):
pass
def fibonnaci_func(self,n):
return self.c_obj.c_fibonacci(n)
-------------编辑
我确保python3调用了setup.py。但是还是一样的问题.....