f2py2.7 Man page

F2PY(1) General Commands Manual F2PY(1)


f2py – Fortran to Python interface generator


(1) To construct extension module sources:

f2py [] [[[only:]||[skip:]] ] [: …]

(2) To compile fortran files and build extension modules:

f2py -c [, , ]

(3) To generate signature files:

f2py -h …< same options as in (1) >


This program generates a Python C/API file (module.c) that
contains wrappers for given Fortran or C functions so that they can be
called from Python. With the -c option the corresponding extension
modules are built.


Write signatures of the fortran routines to file and
exit. You can then edit and use it instead of . If ==stdout then the signatures are
printed to stdout.

Names of fortran routines for which Python C/API functions will
be generated. Default is all that are found in .

skip: Ignore fortran functions that follow until `:’.

only: Use only fortran functions that follow until `:’.

: Get back to mode.

Name of the module; f2py generates a Python/C API file module.c or extension module . Default is

Do [not] lower the cases in . By default, –lower
is assumed with -h key, and –no-lower without -h key.

All f2py generated files are created in . Default is

Overwrite existing signature file.

Create (or not) module.tex. Default is

Create ‘incomplete’ LaTeX document (without commands \document‐
class, \tableofcontents, and \begin{document}, \end{document}).

Create (or not) module.rst. Default is

Create C/API code that reports the state of the wrappers during
runtime. Useful for debugging.

Add CPP #include statement to the C/API code.
should be in the format of either `”filename.ext”‘ or `‘. As a result will be included just
before wrapper functions part in the C/API code. The option is
depreciated, use `usercode` statement in signature files

Create Fortran subroutine wrappers to Fortran 77 functions.
–wrap-functions is default because it ensures maximum portabil‐
ity/compiler independence.

–help-link [..] List system resources found by system_info.py. [..] may contain
a list of resources names. See also –link- switch

Run quietly.

Run with extra verbosity.

-v Print f2py version ID and exit.

–include_paths path1:path2:…
Search include files (that f2py will scan) from the given direc‐



The following options are effective only when -c switch is used.

List available Fortran compilers [DEPRECIATED].

Specify Fortran compiler type by vendor.

Specify C compiler type (as defined by distutils)

–fcompiler-exec= Specify the path to F77 compiler [DEPRECIATED].

–f90compiler-exec= Specify the path to F90 compiler [DEPRECIATED].

List available Fortran compilers and exit.

–f77exec= Specify the path to F77 compiler.

–f90exec= Specify the path to F90 compiler.

Specify F77 compiler flags.

Specify F90 compiler flags.

Specify optimization flags.

Specify architecture specific optimization flags.

Compile without optimization.

Compile without arch-dependent optimization.

Compile with debugging information.



The following options are effective only when -c switch is used.

Link extension module with as defined by numpy_distu‐
tils/system_info.py. E.g. to link with optimized LAPACK
libraries (vecLib on MacOSX, ATLAS elsewhere), use
–link-lapack_opt. See also –help-link switch.

-L/path/to/lib/ -l

-D -U -I/path/to/include/

.o .so .a

Macros that might be required with non-gcc Fortran compilers.

To print out a performance report of F2PY interface when python
exits. Available for Linux.

To send a message to stderr whenever F2PY interface makes a copy
of an array. Integer sets the threshold for array sizes
when a message should be shown.

Python 1.5.2 or higher (2.x is supported).

Numerical Python 13 or higher (20.x,21.x,22.x,23.x are supported).

Optional Numarray 0.9 or higher partially supported.

numpy_distutils from Scipy (can be downloaded from F2PY homepage)




For instructions on reporting bugs, see



Pearu Peterson

Main website: http://cens.ioc.ee/projects/f2py2e/

User’s Guide: http://cens.ioc.ee/projects/f2py2e/usersguide/

Mailing list: http://cens.ioc.ee/mailman/listinfo/f2py-users/

Scipy website: http://www.numpy.org


Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Pearu Peterson

NumPy License