review and run this simple test and post any errors...
There were no errors from the "etest" script on my FreeBSD system, just the expected output of the LANG and PWD variables.
/bin/sh uname -a [ -e etest ] && exit 1 cat << EOF > etest #!/usr/bin/env -S -i /usr/local/bin/python import os os.putenv('LANG', 'FOO') os.system('/usr/bin/env') os.putenv('LANG', 'BAR') os.system('/usr/bin/env') EOF chmod 0755 etest sudo -u _tor ./etest