使用Python 3导入f2py模块时未定义的符号

时间:2015-03-16 15:23:55

标签: python python-3.x fortran fortran90 f2py

我正在尝试使用f2py编译一个最小的Fortran90子程序,以便与Python 3一起使用。当我使用Python 2.7时它正在工作,但是当它在Python 3文件中导入时,我收到一条错误消息。我需要它在Python 3中工作。

我的Fortran子程序:

subroutine test(a,b)
    implicit none

    integer, intent(in) :: a
    integer, intent(out) :: b

    b = a*2
end subroutine

这是我编译的方式:

f2py -c test.f90 -m test 

然后我尝试像Python一样导入Python 3

import test

并收到此错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/.../hello.so: undefined symbol: PyCObject_Type

我已经搜索过这个错误,但发现没有什么对我有用。

1 个答案:

答案 0 :(得分:2)

正如@cdarke指出的那样,我使用的是错误版本的f2py。用f2py3.4编译修复了这个问题。