如何在 PyCharm 中为运行配置设置默认工作目录 [英] How to set the default working directory for run configurations in PyCharm

查看:113
本文介绍了如何在 PyCharm 中为运行配置设置默认工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想运行我们众多的 Python 脚本之一时,我点击了运行,这会创建一个新的运行配置.该配置的工作目录是 python 脚本文件所在的文件夹.相反,它应该从项目范围的固定文件夹中运行.我想以某种方式设置它,但我真的不知道为什么,这有点奇怪,因为我希望很多人都想要这个功能.你知道如何解决这个问题吗?

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?

推荐答案

如果单击右上角的当前选择的运行配置时出现的子菜单中的 Editconfiguration... 按钮在 PyCharm 中,您可以通过从 Templates(也称为 Defaults 在 2018 之前的版本中)并指定所需的值.

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.

在创建新的运行配置之前不要忘记点击Apply/OK,它现在应该包含您指定的默认值!

Don't forget to hit Apply/OK before creating new run configurations, which should now contain the default values you specified!

据我所知,这些默认值是一个项目的本地设置.另请参阅:https://www.jetbrains.com/help/pycharm/2016.2/creating-and-editing-run-debug-configurations.html

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

这篇关于如何在 PyCharm 中为运行配置设置默认工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆