【发布时间】:2020-04-28 11:39:51
【问题描述】:
这是python代码
import subprocess
cmd = "HelloWorld.c"
# Example
# cmd = HelloWorld.c
print("Hey this is Python Script Running\n")
subprocess.call(["gcc", cmd]) # For Compiling
subprocess.call("./a.out", shell = True)
# end thats all
这是 C 代码
#include<stdio.h>
int main()
{
printf("Hello World\n");
printf("This C program Running\n");
return 0;
}
这是错误代码。
嘿,这是正在运行的 Python 脚本
Traceback (most recent call last):
File "C:/Users/Yogi/PycharmProjects/Last_Subprocess_Try/Subprocess/Test.py", line 7, in <module>
subprocess.call(["gcc", cmd]) # For Compiling
FileNotFoundError: [WinError 2] The system cannot find the file specified
Process finished with exit code 1
【问题讨论】:
-
您的搜索路径中有
gcc吗?如果我调用一个不存在的可执行文件,我只能得到那个错误。 -
我正在运行这个 i Pycharm Community edition 2019,你能详细说明如何添加 GCC 路径。
标签: python python-3.x subprocess