1

enter image description hereI am trying to execute a simple python cmd command like C:\Users> python swaggerpythonfile.py < Documents/inputfile/swagger.yaml > Documents/outputfile/doc.html as a python script in a maven project. This command simpy takes a .yaml file and convert it to html file by executing python file swaggerpythonfile.py and works fine from my cmd. However, I need to put it as a a python script in a maven project so i tried to follow the exec-maven-plugin documentation a link! . But i am getting an error.

[ERROR] Command execution failed. java.io.IOException: Cannot run program "python" (in directory "D:\DocAuth\modules\subjectstore"): CreateProcess error=2, The system cannot find the file specified

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
                <configuration>
                    <executable>python</executable>
                    <workingDirectory>${basedir}</workingDirectory>
                    <arguments>
                        <argument>swagger-yaml-to-html.py</argument>  
                        <argument>generated/inputfile/swagger-ui/swagger.yaml</argument>
                      <argument>target/outputfile/doc.html</argument>
                    </arguments>

                </configuration>
                <id>python_build</id>
                <phase>generate-resources</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (python_build) on project

ERROR OUTPUT IMAGE

1
  • I have resolved the error. Instead of <executable>python</executable> we need to provide path to python.exe file like <executable>C:/users/../python.exe</executable> and then it works. Commented Aug 6, 2019 at 17:00

1 Answer 1

3

I see in your comment that you solved this by including the full path to the Python executable, but instead you can add Python to your PATH (which I recommend because this is probably not the only time you are going to use Python).

You can add the Python folder to your PATH with this command:

setx path "%path%;<full-path-to-Python-base-folder>"

Or follow the instructions here: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

Note: I found when developing in Eclipse that I had to restart it for it to pick up changes in the PATH. In general, you will probably have to restart applications when changing environment variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.