1

How can I export an environment variable from Python?

# I want to export a variable in python the same way you would in bash 
export my_var="foo"
# The variable can be set in Python but it won't stay outside of the python session since it's not exported.
os.environ['my_var'] = 'bar'
J'e
  • 3,014
  • 4
  • 31
  • 55
  • What python IDE are you using? In Jupyter Lab you can just set the environment variable with `os.environ['my_var'] = 'bar'` and never need to set it again. In PyCharm you set it by editing your configurations. – It_is_Chris Feb 23 '23 at 16:23

0 Answers0