当试图在Golang中裁定Python时,执行格式错误
我正在尝试编写一个 cli 来执行 https://github.com/timeopochin/GanTTY。当在终端中执行时,使用
python3 ./GanTTY/main.py gantt test
它将创建一个新的交互式甘特图。然而,当我在我的 go 代码中执行此操作时,像这样
{
Name: "project",
Usage: "add a new project with gantt chart",
Action: func(c *cli.Context) error {
cmd := exec.Command("./GanTTY/main.py", "gantt", "test")
err:= cmd.Run()
if err != nil {
log.Fatal(err)
}
fmt.Println("opend project")
return nil
},
},
并运行 go 程序,
go run program.go add project //"add" and "project" are command and sub command
它给了我这个错误
2022/04/03 11:42:19 fork/exec ./GanTTY/main.py: exec format error
exit status 1
Im trying to write a cli that execute a python file from https://github.com/timeopochin/GanTTY. When excute in terminal using
python3 ./GanTTY/main.py gantt test
it will create a new interactive gantt chart. However when i do this in my go code, like this
{
Name: "project",
Usage: "add a new project with gantt chart",
Action: func(c *cli.Context) error {
cmd := exec.Command("./GanTTY/main.py", "gantt", "test")
err:= cmd.Run()
if err != nil {
log.Fatal(err)
}
fmt.Println("opend project")
return nil
},
},
and run the go program
go run program.go add project //"add" and "project" are command and sub command
it gives me this error
2022/04/03 11:42:19 fork/exec ./GanTTY/main.py: exec format error
exit status 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在Windows中添加
python3
或cmd.exe/c python3
。使用cmd.dir相对于当前WD设置Python文件的目录
You need to add
python3
orcmd.exe /c python3
in windows.use cmd.Dir to set directory of python file relative to current wd