2

我正在尝试使用 Fortran 代码创建一个 Python 模块f2py。我已经为我的项目设置了一个 Makefile。我在 Windows 7 上使用 MinGW 和 Python 3.2.2。当我运行

f2py.py -c --compiler=mingw32 -m itf itimes-f.f

一切都编译并运行良好。但是,当我在 Makefile 中创建目标并运行它时,它会执行以下操作:

> make compilef
f2py.py -c --compiler=mingw32 -m itf itimes-f.f
process_begin: CreateProcess(NULL, env python.exe C:\Python32\Scripts\f2py.py -c
 --compiler=mingw32 -m itf itimes-f.f, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [compilef] Error 2

为什么不make运行命令,我该如何解决?

编辑:运行输出中显示的命令不起作用:

> env python.exe C:\Python32\Scripts\f2py.py -c --compiler=mingw32 -m itf itimes-f.f
'env' is not recognized as an internal or external command,
operable program or batch file.

但是,以下方法确实有效:

> python.exe C:\Python32\Scripts\f2py.py -c --compiler=mingw32 -m itf itimes-f.f

编辑 2:这引发了另一个问题 - 什么是env以及为什么要make添加它?

编辑 3:根据 Florian 的评论,似乎是env由于makef2py.py 中存在 shebang 行而添加的。#我编辑了 f2py.py,在 shebang 前面添加了一个附加项。我现在有以下问题:

>make compilef
f2py.py -c --compiler=mingw32 -m itf itimes-f.f
process_begin: CreateProcess(C:\Python32\Scripts\f2py.py, f2py.py -c --compiler=
mingw32 -m itf itimes-f.f, ...) failed.
make (e=193): Error 193
make: *** [compilef] Error 193
4

1 回答 1

3

好的,这只是编写 makefile 的惯例,因此它们可以在标准的 unix 环境中运行。尽管如此,make 来自 *nix,如果你已经安装了 make,那么你可能拥有提供基本工具的 msys,并且脚本以 unix 方式执行,不像 windows 那样......

在 Windows 上使用 mingw-make 为我工作的示例 makefile:

all:
    ./test.py

test.py一个shebang#!C:\\Python27\\python.exe

或者如果 python 在 PATH#!python中就足够了,如下所示:

all:
    python test.py
于 2012-05-30T20:23:48.770 回答