I'm trying to imitate export Key_value="My value"
from Linux on my Windows computer but in my terminal it doesn't work. I saw that maybe I should use SET
instead export
but when I print my environment dictionary my key and value aren't there, only the normal OS values.
Asked
Active
Viewed 42 times
-2

John Kugelman
- 349,597
- 67
- 533
- 578

Rodrigo Reyes
- 3
- 4
-
Does this answer your question? [How to set environment variables in Python?](https://stackoverflow.com/questions/5971312/how-to-set-environment-variables-in-python) – tfw Nov 03 '20 at 19:37
1 Answers
-1
The command in the cmd console is:
setx your_key_value "your value"
You can do it manually too if you go to "environmental variables" using windows menu and typing that, then go to environmental variables and add the one that you want to insert.
My problem then was that I set it but it was not reflected in the os.environment
dictionary. I restarted my computer and tried again and there it was. I think that OS variables are set only when you start your computer.

John Kugelman
- 349,597
- 67
- 533
- 578

Rodrigo Reyes
- 3
- 4