can't find '__main__' module in
2019-07-27 本文已影响0人
晚来天欲雨
使用linux的库函数:execvp()来调用python脚本时,会报这个错。
解决方法:需要执行的python文件使用绝对路径来指定,就像这样:
char *args[] = {"/usr/bin/python3", "/home/zgy/test.py", NULL};
int res = execvp(args[0], args);
if (res == -1){
perror("Error:");
}