user1985157
user1985157

Reputation:

Undefined symbol when importing f2py module, using Python 3

I am trying to compile a minimal Fortran90 subroutine with f2py, to use with Python 3. It is working when I use Python 2.7, but when to import it in a Python 3 file, I get an error message. I need it to work in Python 3.

My Fortran subroutine:

subroutine test(a,b)
    implicit none

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

    b = a*2
end subroutine

This is how I compile:

f2py -c test.f90 -m test 

Then I try to import in Python 3 like so

import test

and get this error:

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

I have searched for this error, but found nothing that makes sense to me.

Upvotes: 3

Views: 3708

Answers (1)

user1985157
user1985157

Reputation:

As @cdarke pointed out, I was using a wrong version of f2py. Compiling with f2py3.4 fixed the problem.

Upvotes: 3

Related Questions