Domanda

This is a very newbie question, but after searching in Google for a while, I haven't been able to find a solution. I'm writing a Python code using Eclipse (in Linux Mint) which needs some routines written in Fortran 77 (the code is in a file named fortran_code.f). I've used f2py to get the file fortran_code.so. This file is in the same folder as the Python code (../workspace/python_project/src). The Python code only includes:

import fortran_code
a = 10
fortran_code.fortran_subroutine(a)

Once an again, the result is:

Traceback (most recent call last):   File
"/home/user/Documents/workspace/python_project/src/Main.py", line 7,
in <module>
import fortran_code ImportError: /home/user/Documents/workspace/python_project/src/fortran_code.so:
undefined symbol: PyCObject_Type

The Fortran subroutine code is:

SUBROUTINE fortran_subroutine(a) 
REAL*8, intent(in) :: a 
REAL*8 b 
b=a*2 
end subroutine fortran_subroutine 

To get the .so file (fortran_code.so) I use:

f2py -c fortran_code.f -m fortran_code 

The version of f2py is 2. And the version of Python is 2.7.4

Any help to solve this problem would be very useful.

Thanks!

È stato utile?

Soluzione

In order to make it work I had to modify the Python Interpreter from Python 3.2 to Python 2.7 (since f2py produces code for Python 2.7). After editing a new Python module everything worked fine!!!

Thanks for all suggestions and comments, which were really helpful.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top