php中运行python 脚本使用g++ 生成不了源程序

php中运行python 脚本使用g++ 生成不了源程序

问题描述:

我最近在做一个online judge平台,使用的是php + python开发,测试的文件为cpp文件。

系统为windows Serever 2012 R2(服务器电脑)

已安装G++、python 3、php7.4.3和Apache2.4

我在php中使用

exec("python test.py")

调用同路径下的test.py文件,

test.py中使用

#testPath = "Judging\\20201212552"
temp = subprocess.Popen("D:\\MinGw\\bin\\g++.exe main.cpp -o a.exe",cwd = testPath,stdout = txt2,stderr=txt1)
temp.wait()
#若去掉g++前的路径,会提示g++不是内部或者外部命令,但是我添加了环境变量(全局)
#temp = os.system("g++ -main.cpp -o a.exe")错误相同

调用g++,最后却无法生成a.exe可执行文件。(用Everything搜索,全盘都没有a.exe)

奇怪的是,我在本地服务器(个人电脑windows10)执行相同的操作,则一切正常,在服务端直接运行test.py也一切正常。请问怎样才能编译出a.exe文件?

你的Python 程序在 服务器上有运行 exe 的权限么?