I want to modified the environment variable via python script/file.
I tried using os.environ
but it does not work, as below:
export TARGET=original_target_value
python
import os
print(os.environ["TARGET"]) # "original_target_value"
os.environ["TARGET"] = "modified_target_value"
print(os.environ["TARGET"]) # "modified_target_value"
quit()
import os
print(os.environ["TARGET"]) # "original_target_value" # Parent TARGET value didn't chang
Python | os.environ object: We can also modify os.environ but any changes will be effective only for the current process where it was assigned and it will not change the value permanently.
Is there anyway to change the environment variables permanently (change the parent environment variable)?