Python 使不';t运行.py文件
我正在尝试使用Python 使不';t运行.py文件,python,numpy,makefile,f2py,Python,Numpy,Makefile,F2py,我正在尝试使用f2py从Fortran代码创建Python模块。我已经为我的项目设置了一个Makefile。我正在Windows7上使用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 itim
f2py
从Fortran代码创建Python模块。我已经为我的项目设置了一个Makefile。我正在Windows7上使用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
似乎是由make
添加的,因为f2py.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
好的,只需编写makefiles,使其在标准unix环境中运行。
尽管如此,make来自*nix,如果您安装了make,那么您可能有提供基本工具的msys,并且脚本是以unix方式执行的,不像windows那样
在windows上使用mingw make为我提供的makefile示例:
all:
./test.py
使用test.py
具有#的shebang!C:\\Python27\\python.exe
或者如果python在路径#中!python已经足够了,因为:
all:
python test.py
当您尝试运行错误消息中给出的命令时?@IgnacioVazquez Abrams,您指的是哪个命令?以env
@IgnacioVazquez Abrams开头的命令,请参见edit.f2py.py可能以这样的行开头:#/usr/bin/env python
。这就是env
的来源env
只需调用python
解释器(请参阅)