我在 Linux Mint 下使用 python 2.7,我有一些 fortran 代码,我使用 f2py 将其导入到 python 代码中。
所以我输入终端:
f2py -c my_module.f90 -m my_module
它工作正常。
现在我想在 python 代码中而不是在终端中使用 f2py。我尝试过类似的东西
import os
os.system("f2py -c my_module.f90 -m my_module")
但它不起作用。这就是我得到的:
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 "module_name" sources
f2py options: []
f2py:> /tmp/tmpfhVUFI/src.linux-x86_64-2.7/module_namemodule.c
creating /tmp/tmpfhVUFI
creating /tmp/tmpfhVUFI/src.linux-x86_64-2.7
Reading fortran codes...
Post-processing...
Post-processing (stage 2)...
Building modules...
error: f2py target file '/tmp/tmpfhVUFI/src.linux-x86_64-2.7/module_namemodule.c' not generated
fortran 和 python 代码都在同一个目录下
我想我可能必须使用 distutils,但我不知道如何
任何想法都会有所帮助
谢谢