I have some instrument which requires environment variable which I want to set automatically from python code. So I tried several ways to make it happen, but none of them were successful. Here are some examples:
I insert following code in my python script
import os os.system("export ENV_VAR=/some_path")
I created bash script(env.sh) and run it from python:
#!/bin/bash export ENV_VAR=some_path #call it from python os.system("source env.sh")
I also tried
os.putenv()
andos.environ*["ENV_VAR"] = "some_path"
Is it possible to set(export) environment variable using python, i.e without directly exporting it to shell?