pycharm not updating with environment variables

2019-01-18 11:54发布

when I update my environmental variables (I use vim to edit ~/.bashrc) PyCharm does not get the updates right away, I have to shut down the program, source ~/.bashrc again, and re-open PyCharm

Any way to have PyCharm source the changes automatically or without shutting down?

7条回答
Fickle 薄情
2楼-- · 2019-01-18 12:33

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

C:\
λ "C:\Program Files\JetBrains\PyCharm 2017.2.1\bin\pycharm64.exe"
查看更多
可以哭但决不认输i
3楼-- · 2019-01-18 12:36

In my case pycharm does not take env variables from bashrc even after restarting

查看更多
爷、活的狠高调
4楼-- · 2019-01-18 12:44

This is simply how environment variables work. If you change them you have to re-source your .bashrc (or whatever file the environment variables are located in).

查看更多
爷的心禁止访问
5楼-- · 2019-01-18 12:51

I know this is very late, but I encountered this issue as well and found the accepted answer tedious as I had a lot of saved configurations already.

The solution that a co-worker told me is to add the environment variables to ~/.profile instead. I then had to restart my linux machine and pycharm picked up the new values. (for OSX, I only needed to source ~/.profile and restart pycharm completely)

One thing to be aware is that another coworker said that pycharm would look at ~/.bash_profile so if you have that file, then you need the environment variables added there

查看更多
SAY GOODBYE
6楼-- · 2019-01-18 12:53

In case you are using the "sudo python" technique, be aware that it does not by default convey the environment variables.

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

sudo -E /path/to/python/executable "$@"
查看更多
时光不老,我们不散
7楼-- · 2019-01-18 12:54

When any process get created it inherit the environment variables from it's parent process (the O.S. itself in your case). if you change the environment variables at the parent level, the child process is not aware of it.

PyCharm allows you to change the environment variables from the Run\Debug Configuration window. Run > Edit Configurations > Environment Variables ->

Images

查看更多
登录 后发表回答