2012-06-11 32 views
3

這是構建文件:獲得Ant構建錯誤:不能運行程序「蟒蛇」

<exec executable="python" failonerror="true"> 
    <arg line="${installer.izpack.dir}/utils/wrappers/izpack2exe/izpack2exe.py"/> 
    <arg line="--file=${basedir}/installer/EasyIT-installer.jar"/> 
    <arg line="--output=${basedir}/installer/EasyIT-installer.exe"/> 
    <arg line="--no-upx"/> 
</exec> 

和輸出:

BUILD FAILED 
E:\Java Projects\Spark Projects\EastIT - Copy\build\build.xml:873: Execute failed: java.io.IOException: Cannot run program "python" (in directory "E:\Java Projects\Spark Projects\EastIT - Copy"): CreateProcess error=2, The system cannot find the file specified 
     at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) 
     at java.lang.Runtime.exec(Runtime.java:615) 
     at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:8 62) 
     at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481) 
     at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495) 
     at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631) 
     at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672) 
     at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498) 
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) 
     at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:43) 
     at java.lang.reflect.Method.invoke(Method.java:601) 
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
     at org.apache.tools.ant.Task.perform(Task.java:348) 
     at org.apache.tools.ant.Target.execute(Target.java:392) 
     at org.apache.tools.ant.Target.performTasks(Target.java:413) 
     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) 
     at org.apache.tools.ant.Project.executeTarget(Project.java:1368) 
     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java :41) 
     at org.apache.tools.ant.Project.executeTargets(Project.java:1251) 
     at org.apache.tools.ant.Main.runBuild(Main.java:811) 
     at org.apache.tools.ant.Main.startAnt(Main.java:217) 
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) 
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) 
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified 
     at java.lang.ProcessImpl.create(Native Method) 
     at java.lang.ProcessImpl.<init>(ProcessImpl.java:189) 
     at java.lang.ProcessImpl.start(ProcessImpl.java:133) 
     at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021) 
     ... 23 more 


Total time: 50 seconds 
+0

嘛,Python安裝? – TheLQ

回答

10

確保python是在你的PATH運行構建,或在exec任務中爲您的python可執行文件指定絕對路徑。

查看exec task的文檔,瞭解有關使用Windows與非Windows的任何具體說明。請注意,您的特定錯誤有提到:

A common problem is not having the executable on the PATH. In case you get an error message Cannot run program "...":CreateProcess error=2. The system cannot find the path specified. have a look at your PATH variable. Just type the command directly on the command line and if Windows finds it, Ant should do it too. (Otherwise ask on the user mailinglist for help.) If Windows can not execute the program add the directory of the programm to the PATH (set PATH=%PATH%;dirOfProgram) or specify the absolute path in the executable attribute in your buildfile.