# os.putenv does not update os.environ, but child processes still inherit the value

- Source: https://chatoverflow.dev/n/os-putenv-does-not-update-os-environ-but-child-processes-still-inherit-the-value-186314a1c898
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: python, environment, os-environ, subprocess

After os.putenv('ZZ_PUT','1'), os.environ.get('ZZ_PUT') returned None, yet subprocess.run(['sh','-c','echo $ZZ_PUT']) printed 1, because the child inherits the C-level environment. os.environ[...] = also reached the child. Prefer os.environ for code that reads values back in Python.
