0
func execPython(fPath, colName, srv  string) (){
fmt.Println("Inside execPython")
cmd:= "python rfsvmchurn.py"
arg0 := "-fp " + fPath
arg1 := "-srv " + srv
arg2 := "-col " + colName
if err := exec.Command(cmd, arg0, arg1, arg2).Run(); err != nil {
    fmt.Println("Python Execution Error :",err)
}

}

getting error Python Execution Error : exec: "python rfsvmchurn.py": executable file not found in $PATH

9
  • 1
    Perhaps make rfsvmchurn.py an argument instead of including it as part of cmd. Commented Jan 27, 2016 at 2:03
  • Tried rfsvmchurn.py as argument, it also gives the same error Commented Jan 27, 2016 at 2:13
  • The exact same error? Commented Jan 27, 2016 at 2:14
  • Python Execution Error : exec: "python ": executable file not found in $PATH Commented Jan 27, 2016 at 2:22
  • Try using the full absolute path to the python script. If that works then the python script is not in a place that your program can find it (either in the PATH as the error says or your program's working directory). Commented Jan 27, 2016 at 2:36

1 Answer 1

1

Your issue is probably that you're passing flags and their arguments as a single string. You should instead do:

func execPython(fPath, colName, srv  string) (){
    fmt.Println("Inside execPython")
    arg0 := "-fp " + fPath
    arg1 := "-srv " + srv
    arg2 := "-col " + colName
    cmd := exec.Command("python", "rfsvmchurn.py", "-fp", fPath, "-srv", srv, "-col", colName)
    if err := cmd.Run(); err != nil {
        fmt.Println("Python Execution Error :",err)
    }
}
Sign up to request clarification or add additional context in comments.

5 Comments

Getting same error Python Execution Error : exec: "python rfsvmchurn.py": executable file not found in $PATH
Try ./rfsvmchurn.py instead?
Wait, actually, are you sure you passed "python" and "rfsvmchurn.py" as separate arguments? That error makes it sound like you had them as the same string.
Yes I tried like that, and now I am getting this error Python Execution Error : exit status 1
Thanks, its working. the exit status 1 is due to issue in python file

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.