f2py 创建然后立即覆盖临时文件

发布于 2025-01-01 09:05:08 字数 2420 浏览 0 评论 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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不即不离 2025-01-08 09:05:08

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文