Prevent PyCharm from auto creating new config when run/debug(防止 PyCharm 在运行/调试时自动创建新配置)
问题描述
当我通过右键运行/调试运行我的代码时,PyCharm 有时会自动创建一个名为 FILENAME(1)
的新配置,并且新配置是根据默认配置创建的,而不是我以前的旧配置(通常默认称为 FILENAME
).
如下图,右上角仍然显示我的旧配置(与默认不同),但在右键菜单中运行显示以(1)
结尾的配置,不存在然而(在编辑配置中),PyCharm 在我单击右键菜单中的运行后会自动创建它.但是,使用右上角的按钮运行可以正确运行没有 (1)
的原始配置(这意味着原始配置仍然正确链接到该文件并且没有损坏).
我该如何解决这个问题?
IntelliJ IDEA 中似乎也存在同样的问题(我在 IntelliJ 中无法复现,但我记得好像遇到过一次).
PyCharm 版本:2020.3.2 Pro 带 edu 许可证
附言我还找不到任何模式,但这不是临时问题,无论何时发生,它都会永远保持为 (1)
,重新启动 PyCharm 甚至计算机都无济于事,这是我唯一的方法发现是把所有相关的配置都去掉,重新从头设置,很烦.
PyCharm 会根据您运行项目的方式生成临时配置(对应于 Shift + F10 的 2 次可能运行之间存在差异 或 Alt + Shift + F10.)为避免创建临时配置,请运行明确使用您打算使用的配置的快捷方式或图标.
在 IDE 的
早期版本:您可以在模板中配置临时运行配置的最大数量,对于 PyCharm 的版本
When I run my code by right click-run/debug, PyCharm sometimes creates a new Config automatically called FILENAME(1)
, and the new config is created according to default config rather than my previous old config (normally called FILENAME
by default).
As shown in image below, upper right corner still shows my old config (different from default), but run in right click menu is showing a config ending with (1)
, which does not exist yet (in edit config), PyCharm automatically creates it after I click on run in right click menu. However, running with the upper right button correctly runs the original config without the (1)
(which means the original config still correctly links with this file and is not corrupted).
How do I fix this?
The same problem seems to exist in IntelliJ IDEA (I am unable to reproduce in IntelliJ, but I seem to remember that I encountered once).
PyCharm version: 2020.3.2 Pro with edu license
P.S. I can't find any pattern yet, but it is not a temporary issue, whenever it occurs, it stays as (1)
forever, restarting PyCharm or even computer doesn't help, the only way I found is to remove all related config and set thing up from the beginning again, which is very annoying.
A temporary configuration is generated by PyCharm depending how you run the project (there is a difference between the 2 possible runs corresponding to Shift + F10 or Alt + Shift + F10.) To avoid temporary configurations being created run a shortcut or icon that explicitly uses the configuration you intend to use.
In the IDE's "Edit Configurations" dialogue you should delete any temporary configurations, choose the configuration you want to use for your project, possibly using Alt + Shift + F10 to make sure. Do this before trying the right-lick popup shortcut and it should work.
If the above still isn't enough, the temporary configurations are saved in a file. You can check the contents of the file but it is recommendable trying to use the IDE dialogues to solve the problem instead of editing the file directly.
Temporary run/debug configurations
Temporary Run/Debug configurations are recorded in the /.idea/workspace.xml file under the Run Manager section.
Update: Configuring the maximum number of temporary run configurations was disabled in PyCharm 2021.1 but is again possible since PyCharm 2021.2. It can now be configured by going to File
>
Settings
>
Advanced Settings
>
IDE
>
Temporary Run/Debug configurations limit
see the documentation and the screenshot:
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.
Earlier versions: You can configure the maximum number of temporary run configurations in the Template, for versions of PyCharm 2020.1 through 2020.3 see the documentation and the screenshot:
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.
这篇关于防止 PyCharm 在运行/调试时自动创建新配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:防止 PyCharm 在运行/调试时自动创建新配置
基础教程推荐
- 用于分类数据的跳跃记号标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01