0

我最近在我的计算机上安装了 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.
4

1 回答 1

3

您缺少 Python 开发文件(例如 Python.h 标头)。从您的输出来看,您似乎在 Linux 上。如果是这种情况,那么您只需要安装python-dev软件包(至少在 Debian 和 Ubuntu 上就是这样)或python-devel.

对于 Python 3,您可能需要python3-devpython3-devel取决于您的 Linux 发行版。

于 2012-03-16T16:38:16.787 回答