Pycharm does not update with environment variables

when I update my environment variables (I use vim to edit ~ / .bashrc) PyCharm does not receive the update immediately, I have to close the program again, the source ~ / .bashrc and reopen PyCharm

In any case, so that PyCharm automatically installs the changes or does not disconnect?

+7
environment-variables pycharm
source share
6 answers

When a process is created, it inherits the environment variables from it of the parent process (the OS itself in your case). if you change the environment variables at the parent level, the child process is not aware of this.

PyCharm allows you to change environment variables from the Run \ Debug window. Run> Change Configurations> Environment Variables →

Images

+6
source share

Pycharm supports its own version of environment variables, and they are not obtained from the shell.

It seems that if pycharm is run from virtualenv or a shell containing the specified variables, it will load with them, however it is not dynamic.

the answer below has a settings.py script parameter so that virtualenv updates and saves the settings. Whether this is a complete solution to your question or not, I'm not sure.

Pycharm: set an environment variable to run manage.py

+1
source share

I recently discovered a workaround in windows. Close Pycharm, copy the command to launch Pycharm directly from the shortcut and run it in a new terminal window: cmd, cmder, etc.

C:\ λ "C:\Program Files\JetBrains\PyCharm 2017.2.1\bin\pycharm64.exe" 
+1
source share

In my case, pycharm does not accept env variables from bashrc even after restart

+1
source share

This is just how environment variables work. If you change them, you must reload your .bashrc (or any other file that contains the environment variables).

0
source share

If you use the "sudo python" method, keep in mind that it does not pass environment variables by default.

To pass environment variables defined in the PyCharm launch configuration correctly, use the -E switch:

 sudo -E /path/to/python/executable " $@ " 
0
source share

All Articles