gpt4 book ai didi

Maven exec 插件 - 执行 python 脚本

转载 作者:行者123 更新时间:2023-12-03 14:54:18 45 4
gpt4 key购买 nike

我在 Win 7 上使用 maven 来构建应用程序。我使用 exec 插件来调用 python 脚本。

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>create-dir</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>src/main/upgrade/create.py</executable>
<arguments>
<argument>ChangeSet.txt</argument>
</arguments>
</configuration>
</plugin>

构建项目时出现以下错误。
Embedded error: Cannot run program "pathToScript/create.py" CreateProcess error=193, %1 is not a valid Win32 application

我确实安装了 python 并添加到 %PATH 变量中。

如何修复它,使其独立于操作系统平台工作?

。:-编辑-:。

工作代码片段
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<executable>python</executable>
<workingDirectory>src/main/upgrade/</workingDirectory>
<arguments>
<argument>createChangeSet.py</argument>
</arguments>

</configuration>
<id>python-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>

最佳答案

在 Windows 中,脚本不可执行。可执行文件是python解释器,脚本是它的参数,所以输入<executable>path to your python interpreter</executable>并将脚本添加为 <argument> .我希望同样适用于任何平台,但我不是 Python 专家。

关于Maven exec 插件 - 执行 python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13974445/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com