1

I tried to set a new "System wide environment" variable and tried to access it using python. I put 'PRODUCTION_SERVER'=1 in etc/environment. After rebooting i tested it in python interpreter and it was successful

>>> import os
>>> os.environ.get('PRODUCTION_SERVER')
'1'
>>> 

But when i used the same line inside my flask project in that server it returned None.

import os
print os.environ.get('PRODUCTION_SERVER')

Output

None

Why am i getting different results in same system?

1
  • I used shell without sudo or anything. Can you suggest me a solution ? Commented Feb 13, 2015 at 11:57

1 Answer 1

2

Don't know if this is the problem, but:

The /etc/environment file is only loaded when you log in (it is read by the pam_env PAM module). If your flask service is running an an environment that was created before you changed the /etc/environment file, it would not see new values you have entered into that file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.