【发布时间】:2012-05-30 14:23:11
【问题描述】:
我正在尝试使用 f2py 从 Fortran 代码创建 Python 模块。我已经为我的项目设置了一个 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 的评论,由于 f2py.py 中存在 shebang 行,env 似乎是由 make 添加的。我编辑了 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
【问题讨论】:
-
当您尝试运行错误消息中给出的命令时?
-
@IgnacioVazquez-Abrams,你指的是哪个命令?
-
以
env开头的那个。 -
@IgnacioVazquez-Abrams,见编辑。
-
f2py.py 可能以这样的一行开头:
#!/usr/bin/env python。这就是env的来源。env只需调用python解释器(参见 man page)
标签: python numpy makefile f2py