f2py and Fortran90 gfortran_filename error

Robert Kern robert.kern at gmail.com
Wed Feb 28 00:40:52 EST 2007


Tyler wrote:
> Hello All:
> 
> Since my last post I have attempted to use the f2py program which
> comes with numpy.

It's better to ask these questions on numpy-discussion, instead. There are more
f2py users per capita there.

  http://www.scipy.org/Mailing_Lists

> I am able to create a <module_name>.so file fine;
> however, when I import it into Python, I receive the following
> message:
> 
>>>> import matsolve2
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: ./matsolve2.so: undefined symbol: _gfortran_filename
> 
> 
> The steps I used to create the matsolve2.so file are as follows:
> 
> (1) Created a Fortran90 program matsolve.f90
> 
> Note: The program compiles fine and prints the proper output for the
> simple matrix specified. I have also attached below the file
> matsolve.f90 if it helps at all.
> 
> (2) f2py matsolve.f90 -m matsolve2 -h matsolve2.pyf
> (3) f2py -c matsolve2.pyf --f90exec=/usr/bin/gfortran matsolve.f90
> 
> Note: I had to specify the f90 path as f2py did not automatically find
> it.

You want to specify the *kind* of Fortran compiler such that f2py knows what
compile/link flags to use. Only use the --f90exec option to inform f2py that the
actual executable is named something odd or is in an unexpected place, like
/opt/gfortran/bin/gfortran-4.3, for example. The correct option to use is

  --fcompiler=gnu95

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list