PyCharm, Virtualenv and Environment variables

Hi lovely people,

I started to use PyCharm for developing my Django projects. I'm very impressed about the functionality it has.

But at the moment I'm having one issue. When I try to use environment variables that I have set in the terminal(export DATABASE_ENGINE=mysql) it isn't working:
print os.environ['DB']

Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/admin_raoul/.virtualenv/i-raoul.com/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'DB'

When I check it in the terminal it's working fine. I'm guessing that this error is raised because PyCharm is using a different environment.

Please share your knowledge on how to create environment variables to use with os.environ?

Thanks a lot,


Please sign in to leave a comment.