python calls shell to l2gen error: l2gen not found. How to set env in python script?
Posted: Sun Jun 09, 2019 7:52 am America/New_York
the l2gen can run in terminal. but dont in python. the error is:sh: 1: l2gen: not found.
according to google searching result, the environment variable need to be set again in python script. the method is:
new_env=os.env.copy()
new_env['OCSSWROOT'] = '/usr/local/seadas-7.5.3/ocssw'
returnCode = subprocess.call(l2genshell , env=new_env,shell=True)
there is a problem that environment variables in OCSSW_bash.env can not be add to new_env by using SOURCE command line.
But there is few question/answer to demonstrate how to parse the xxx.env file (OCSSW_bash.env) in python.
How should i add this environment variable in python script? THANKS
according to google searching result, the environment variable need to be set again in python script. the method is:
new_env=os.env.copy()
new_env['OCSSWROOT'] = '/usr/local/seadas-7.5.3/ocssw'
returnCode = subprocess.call(l2genshell , env=new_env,shell=True)
there is a problem that environment variables in OCSSW_bash.env can not be add to new_env by using SOURCE command line.
But there is few question/answer to demonstrate how to parse the xxx.env file (OCSSW_bash.env) in python.
How should i add this environment variable in python script? THANKS