When I want to run one of our many python scripts I hit run, which creates a new run configuration. The working directory for that configuration is the folder in which the python script file resides. Instead, it should run from a project wide fixed folder. I'd like to set that somehow but I really cannot figure out why, which is a bit odd as I'd expect many people to want to have this functionality. Do you know how to pull this off?
Asked
Active
Viewed 1.2k times
1 Answers
40
If you hit the Edit configurations... button in the submenu appearing when clicking on your currently selected run configuration in the top right of PyCharm, you are able to edit the fields (and therefore also the working directory) of Python run configurations by selecting Python from the Templates (also called Defaults in versions pre-2018) and specifying the desired values.
Don't forget to hit Apply/OK before creating new run configurations, which should now contain the default values you specified!
As far as I know, these defaults are local to one project. See also: https://www.jetbrains.com/help/pycharm/2016.2/creating-and-editing-run-debug-configurations.html
Jean-François Corbett
- 36,032
- 27
- 135
- 183
mxscho
- 1,824
- 1
- 15
- 26
-
3Interesting, I didn't know you could add defaults that way. However, if I do as you described and after saving the defaults/python config, and then go to a new file and hit 'run', then its working directory is still set to its path, and not the working directory of the default run configuration? – ikku100 Oct 18 '16 at 13:21
-
5Sorry that I couldn't answer earlier. You probably mean the temporary configuration (that's how PyCharm's documentation is calling it) which is not updating itself. If you rightclick inside a file and hit `Debug`/`Run`, it will search all the existing temporary configurations for one matching the file and run/debug this one. It will not create a new temporary configuration when you rightclick like that. So if you want to have the default settings in these ones, you have to recreate the corresponding temporary configs (or delete them and auto-create them by rickclicking inside the file). – mxscho Oct 18 '16 at 15:34