Python: Exporting environment variables in subprocess.Popen(..)

后端 未结 3 1760
死守一世寂寞
死守一世寂寞 2020-11-30 11:06

I am having an issue with setting an environment variable on a call to subprocess.Popen. The environment variable does not seem to be getting set. Any suggestio

3条回答
  •  有刺的猬
    2020-11-30 11:40

    You should use os.environ.copy() to make it work. It creates a copy of the entire environment dictionary which you can then modify before passing it on to the subprocess, without modifying the current process environment.

    See this answer.

提交回复
热议问题