Environment variable not accessible with Python with sudo

Viewed 2381

I've got an issue with my python script

First, I defined an environment variable as

export TEST=test

My Python script is quite easy "test.py"

import os
print os.environ['TEST']

So when I run it with

~ $ python test.py

I've got the expected result test printed out. However, if I run the script with

~ $ sudo python test.py

I've got an KeyError: 'TEST' error.

What have I missed ?

1 Answers
Related