Python ENV file overwritten by PHP ENV -
i'm working php , laravel framework, , use .env set environment variables. call python scripts php environment, , return result php. problem is, default os.environ
set in python being overridden php's environment.
my code (an example):
<?php //setting laravel environment , loading in $_env variable exec('python script.py');
and python:
print os.environ
print os.environ
return of environment variables set during php environment setup. of default environment variables, such path, either not set or overridden new env.
it took me while diagnose problem. however, limited knowledge of python, how solve proving problematic. there way can reinitialize python environment without affecting php environment, , vice versa? need both processes separate 1 environment-wise, or need set python environment, update old values before returning php.
if knows how go you'd lifesaver.
the child processes inherit environment variables parent processes on startup. no changes in child process' environment ever propagated parent process.
in case, python script child process; inherits environment php script; free changes os.environ
, these wouldn't affect php process @ all, example prepend new path in beginning of path
environment variable
os.environ['path'] = '/home/foo/bar/bin:' + os.environ['path']
as php, changes in $_env
should not inherited child processes, ones explicitly set putenv
should inherited children.
Comments
Post a Comment