"Stop" doesn't kill a python process


for a few days now I have the problem that PyCharm (Professional) can't really end a running process when I click the red stop button. It stops printing stuff, but it's missing the "Process finished with exit code 0" and the python process is still there. If I try to rerun the process, it hangs at "Restarting Console". (If I try to close that, it hangs at "Stopping - Restarting Console")

If I manually kill the python process, I get the "Process finished with exit code 0" and can rerun the process normally. But it's very cumbersome to close every process by hand. Can anybody help me with that?I run Ubuntu 20.04 and the project is on a separate mounted SSD. Oh and I don't have this problem with debugging.


When you press stop button, PyCharm sends SIGTERM signal to the process, but the process can ignore it. The issue is most likely in the process. 

To test this, you can run the code from the terminal outside of IDE and try to send the process SIGINT and SIGTERM signals manually.

To send SIGINT, simply stop the process with Ctrl+C

To send SIGTERM, run the process, open another terminal, and do `kill -15 <pid>`


I'm getting a very similar error, except I have no issue with rerunning the code. After running a script (quite basic one, only 30+ lines) the python console shows like this.  I can rerun the script and everything seems fine.  Everything behaves as expected, except I get the In[3]: at the end, where as before I was getting the Process Finishes at exit code 0.

I can click the red stop button and get the exit code.  But as the original poster mentions, this is cumbersome.



Perhaps you didn't run your scripts in Python Console before that?
If you disable Run with Python Console for your run configuration (Run | Edit Configurations...), then PyCharm will show the exit code as soon as the script execution finishes.


After sometime looking for solutions to this, I did indeed go to the Run Configuration.  I unchecked the Run with Python Console check box and it ran as I wanted. 

What I don't understand, is why did the configuration change like that as I would not have checked that on my own. 


One suggestion I saw was to check Emulate terminal in output console.  I actually have both unchecked and am getting the behavior I want.  What is the meaning behind Emulate terminal in output console?



For me the checking of "Emulate terminal in output console" leads to the effect, that I can start the program

with a keyboard-shortcut, also when the program is running. Before checking the box, I need to click twice the red button for 

stopping the program. But this behaviour is only valid on MacOS.

Hopefully it helps you further.

Best regards




I have the same issue. It started when I added Thread to my code. If I comment out that part of the script it ends just after pressing red square.

Thanks, have a nice day.


Please sign in to leave a comment.