py test.py
, ошибка не возникла. my_env = os.environ.copy()
my_env["PATH"] = "C:/MinGW/bin/gcc.exe" + my_env["PATH"]
subprocess.Popen(cmd, shell=True, env=my_env).wait()
Popen(cmd, shell=True, env={'PATH': 'C:/MinGW/bin/gcc.exe'}).wait()
Popen(cmd, shell=True, env={'PATH': os.getenv('PATH')}).wait()