f2py creating and then immediately overwriting temp files

1k Views Asked by At

I recently installed python and numpy on my computer, and I have a fortran compiler that is recognized by f2py. However, when I try to run a very simple instance of f2py, it all goes to hell. From looking at the error messages, it looks like f2py is creating the temp files necessary to write out the translated C/API, but then it overwrites them and I get the error message below. The fortran code DOES compile on its own.

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "fibl" sources
f2py options: []
f2py:> /tmp/tmpjxR2Ko/src.linux-i686-2.7/fiblmodule.c
creating /tmp/tmpjxR2Ko
creating /tmp/tmpjxR2Ko/src.linux-i686-2.7
Reading fortran codes...
Reading file 'fibl.f' (format:fix,strict)
Post-processing...
Block: fibl
        Block: fib
Post-processing (stage 2)...
Building modules...
Building module "fibl"...
    Constructing wrapper function "fib"...
      fib(a,[n])
Wrote C/API module "fibl" to file "/tmp/tmpjxR2Ko/src.linux-i686-2.7/fiblmodule.c"
adding '/tmp/tmpjxR2Ko/src.linux-i686-2.7/fortranobject.c' to sources.
adding '/tmp/tmpjxR2Ko/src.linux-i686-2.7' to include_dirs.
copying /usr/lib/pymodules/python2.7/numpy/f2py/src/fortranobject.c -> /tmp/tmpjxR2Ko/src.linux-i686-2.7
copying /usr/lib/pymodules/python2.7/numpy/f2py/src/fortranobject.h -> /tmp/tmpjxR2Ko/src.linux-i686-2.7
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Found executable /usr/bin/f77
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize IntelFCompiler
Found executable /opt/intel/bin/ifort
customize IntelFCompiler
customize IntelFCompiler using build_ext
building 'fibl' extension
compiling C sources
C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC

creating /tmp/tmpjxR2Ko/tmp
creating /tmp/tmpjxR2Ko/tmp/tmpjxR2Ko
creating /tmp/tmpjxR2Ko/tmp/tmpjxR2Ko/src.linux-i686-2.7
compile options: '-I/tmp/tmpjxR2Ko/src.linux-i686-2.7 -I/usr/lib/pymodules/python2./numpy/core/include -I/usr/include/ python2.7 -c'
gcc: /tmp/tmpjxR2Ko/src.linux-i686-2.7/fiblmodule.c
/tmp/tmpjxR2Ko/src.linux-i686-2.7/fiblmodule.c:16:20: fatal error: Python.h: No    such file or directory
compilation terminated.
/tmp/tmpjxR2Ko/src.linux-i686-2.7/fiblmodule.c:16:20: fatal error: Python.h: No such file or directory
compilation terminated.
1

There are 1 best solutions below

0
On

You're missing the Python development files (e.g., the Python.h header). From your output, it looks like you're on Linux. If that's the case, then you just need to install the python-dev package (at least that is what it's called on Debian and Ubuntu) or python-devel.

For Python 3 you might need python3-dev or python3-devel depending on your Linux distribution.