Skip to main content
 首页 » 编程设计

python之f2py 没有找到任何编译器

2025年05月04日9mfryf

我安装了 NAG Fortran 编译器。我可以通过调用 nagfor -o helloworld helloworld.f90 来编译 Fortran 代码。如果我使用 f2py -c -m helloworld helloworld.f90 --fcompiler=nagfor 运行 f2py,什么也不会发生。此外,如果我只是运行 f2py 什么也不会发生。 f2py --help-fcompiler 没有输出。

我安装了 Windows 7 并使用 Anaconda Python 发行版。知道我应该如何解决这个问题吗?

请您参考如下方法:

根据 Ian 的评论和 this post我设法运行了 f2py(遗憾的是只能使用 GNU Fortran 编译器)。

我必须将 C:\Loopy\Lib\site-packages\numpy\distutils\fcompiler\gnu.py 中的第 337 行更改为:

pass #raise NotImplementedError("Only MS compiler supported with gfortran on win64") 

此外,我使用 C:\Loopy\Scripts\f2py.py。