I'm new to C++ and I want to run this C++ code using python.
The C++ code
#include <stdio.h>
int main() {
printf("hello this is inside c++ ");
return 0;
}
The Python Code
import subprocess
print("in python file")
subprocess.call(["gcc", "c_file.cpp"])
subprocess.call("./a.out")
print("task is done")
The error I'm getting when I run using the python file
Traceback (most recent call last):
File "C:\Users\Amiru Randil\PycharmProjects\pythonRunC++Code\main.py", line 5, in <module>
subprocess.call(["gcc", "c_file.c"])
File "C:\Python382\lib\subprocess.py", line 349, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Python382\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python382\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
where gccwhen you run it from cmd.exe