阻止 PyCharm 在 run/debug 时自动创建新配置

Prevent PyCharm from auto creating new config when run/debug

当我运行我的代码click-run/debug时,PyCharm有时会自动创建一个名为FILENAME(1)的新配置,并且新配置是根据默认配置创建的而不是我以前的旧配置(默认情况下通常称为 FILENAME)。

如下图,右上角仍然显示我的旧配置(与默认不同),但是右键菜单中的运行显示的是以(1)结尾的配置,这不是存在(在编辑配置中),PyCharm 在我单击右键菜单中的 运行 后自动创建它。但是,运行 右上角按钮正确 运行 没有 (1) 的原始配置(这意味着原始配置仍然正确链接到此文件并且没有损坏)。

我该如何解决这个问题?

IntelliJ IDEA中好像也存在同样的问题(我在IntelliJ中无法重现,不过我好像记得遇到过一次)

PyCharm 版本:2020.3.2 Pro with edu license

P.S。我还找不到任何模式,但这不是暂时的问题,无论何时出现,它都会永远保持 (1),重新启动 PyCharm 甚至计算机都无济于事,这是我找到的唯一方法就是把相关的配置都去掉,重新从头设置,很烦人。

临时配置由 PyCharm 生成,具体取决于您 运行 项目的方式(对应于 Shift + 的 2 个可能的 运行 之间存在差异F10Alt + Shift + F10。)为了避免创建临时配置 运行 明确使用您打算使用的配置的快捷方式或图标。

在 IDE 的 "Edit Configurations" 对话框中,您应该删除任何临时配置,选择您要用于项目的配置,可能使用 Alt + Shift + F10 确认一下。在尝试右键弹出快捷方式之前执行此操作,它应该可以工作。

如果以上还不够,临时配置保存在一个文件中。您可以检查文件的内容,但建议尝试使用 IDE 对话框来解决问题,而不是直接编辑文件。

Temporary run/debug configurations

Temporary Run/Debug configurations are recorded in the /.idea/workspace.xml file under the Run Manager section.


更新: 配置 临时 运行 配置的最大数量 在 PyCharm [=23] 中被禁用=].现在可以通过 File > Settings > Advanced Settings > IDE > Temporary Run/Debug configurations limit 查看文档和屏幕截图:

Run/debug configurations

Temporary — created every time you run or debug functions or tests.

The maximum number of temporary configurations is 5. The older ones are automatically deleted when new ones are added. If necessary, you can increase this limit in Settings/Preferences | Advanced Settings | IDE | Temporary Run/Debug configurations limit.

早期版本:可以在Template中配置最大临时运行个配置,PyCharm2020.1 through 2020.3版本见文档和屏幕截图:

Temporary run/debug configurations

Temporary configurations are marked with semi-transparent icons and are managed the same way as the permanent configurations.

By default, five temporary run/debug configurations are allowed per project, so when you create the sixth configuration, the one created first is removed, and so on. To change this limit, use the Temporary configurations limit field in the Templates page of the Run/debug configurations dialog.