我最近在我的计算机上安装了python和numpy,我有一个被f2py识别的fortran编译器。但是,当我尝试运行一个非常简单的f2py实例时,一切都会变成地狱。通过查看错误消息,看起来f2py正在创建写出已翻译的C / API所需的临时文件,但随后它会覆盖它们,我会在下面收到错误消息。 fortran代码自行编译。
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.
答案 0 :(得分:2)
您缺少Python开发文件(例如,Python.h标头)。从您的输出,看起来你在Linux上。如果是这种情况,那么你只需要安装python-dev
包(至少在Debian和Ubuntu上调用它)。