当我通过Ant运行我的xml代码时出现C:\Users\Sony\Desktop\Project\Workspace\testpython\verify_fam_extended.xml:52: Execute failed: java.io.IOException: Cannot run program "python" (in directory "C:\Users\Sony\Desktop\Project\Workspace\testpython\backend\generated"): CreateProcess error=2, The system cannot find the file specified
错误。
<exec dir="backend/generated" executable="python">
<arg line="toplevel.py"/>
<env key="PYTHONPATH" value="${dsltrans.install.path}:./backend/generated"/>
</exec>
答案 0 :(得分:0)
编辑 python.exe
必须位于可执行路径变量PATH
中定义的目录中。
以下工作示例假定存在C:\Python33\python.exe
<project name="demo" default="main" basedir=".">
<property environment="env" />
<echo>PATH is set as: ${env.PATH}</echo>
<target name="main">
<exec dir="backend/generated" executable="python">
<arg line="--version"/>
</exec>
</target>
</project>
在命令会话中执行
set PATH=C:\Python33;%PATH%
ant
输出
Buildfile: X:\temp\build.xml
[echo] PATH is set as: C:\Python33;...
...
main:
[exec] Python 3.3.0
修改刚检查过。可执行文件可以是executable="python"
或executable="python.exe"
。所以@cdarke是正确的问题是python.exe
不在PATH
。