How to set environment variables in Python?

Environment variables must be strings, so use

os.environ["DEBUSSY"] = "1"

to set the variable DEBUSSY to the string 1.

To access this variable later, simply use


Child processes automatically inherit the environment of the parent process — no special action on your part is required.

Leave a Comment