Reputation: 3089
I have set a default for environment variables under Run > Edit Configurations..., and still, when I make a new PyCharm project, that default is lost, and I have to set the environment variables again.
How can I set the environment variables in such a way that they affect any new PyCharm project I make?
Thanks!
Upvotes: 5
Views: 2104
Reputation: 98
While looking into this today, I found that PyCharm has multiple main locations for adding default environmental variables. While it is a pain, it will cover most use cases.
1) Open File -> New Project Settings
(Image) New Project Settings Location
2) Set default environmental variables in these two locations:
(Image) Terminal and Console Locations in Settings
3) Set environmental variables for Run/Debug Configurations (especially for Python and Python tests)
(Image) Where to find configurations
(Image) Location of Python and Python Tests in Template List
You can always edit other templates to include your variables. These multiple locations also allow you to be specific with your variables (For example, I have my Private PyPi auth token only in the Terminal location). Hope this helps!
Upvotes: 5
Reputation: 718
The defaults you are editing affect only new Run configurations for the project you presently have open. I'm not sure that you can change the defaults for new projects. If it's even possible, I suspect you'll need to "look under the hood" in your $HOME/.PyCharm*/config/
directory.
Upvotes: 1