我想从c运行python脚本。我尝试编译成功,但它给出错误" python不被识别为内部或外部命令,可操作程序或批处理文件"。
#include <iostream>
using namespace std;
// main() is where program execution begins.
int main()
{
std::string filename = "hi.py";
std::string command = "python ";
command += filename;
FILE* in = popen(command.c_str(), "r");
pclose(in);
return 0;
}
答案 0 :(得分:0)
您希望使用python可执行文件的完整路径,例如:
std::string command = "/usr/bin/python ";