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:
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.