PyCharm, Virtualenv and Environment variables
|Answered by Dmitry Filippov|
It makes sense of how you launch PyCharm.
You know, environment variables are per-process attribute. And they inherits via 'exec' syscall from parent to child process.
So if you added some variables via 'export' into your current shell... They are environment variables only in this process = this shell instance. So, to make them available as environment variables in PyCharm, PyCharm must be launched from the shell mentioned (thus pycharm is child process of shell).
environment variables are visible through /proc/[pid]/environ (they are per-process)
so you can do something like
$ps aux | grep pycharm to get its pid.
please check first if environment variables are really in pycharm process)
so if they are there, pycharm becomes parent to python interpreter instance and it must have environment variables inherited.
so print os.environ['DB'] will work fine in case you have DB variable.
for more information on environment variables please check:
$man 7 environ
$man 3 exec