Using python in terminal on a Mac, type
ctrl-z
will stop the python, but not exit it, giving output like this:
>>> [34]+ Stopped python
As you can see, I have stopped 34 python calls.
Although I could use
>>> exit()
to exit python, the questions are:
Is there a short-key to really exit (not just stop) python in terminal? and, why
ctrl-c
does NOT work?
How do I kill all the stopped python?
BTW, how could I type 'ctrl-c' and other hotkeys with a keyboard look?
Thanks!
If you are on a Mac you can also check the version you are running by typing python3 -version in Terminal. You will then see the shell prompt >>> indicating that you are in the Python shell. To exit the python shell, simply enter exit().
In the Terminal app on your Mac, in the window running the shell process you want to quit, type exit , then press Return.
CTRL+d -> Defines EOF (End of File).
CTRL+c -> Will terminate most jobs.
If, however you have written a python wrapper program that calls other python programs in turn, Ctrl-c will only stop the the job that is currently running. The wrapper program will keep running. Worst case scenario, you can do this:
Open up: Applications -> Utilities -> Activity Monitor, Find the process labeled as python, highlight it in the activity monitor then click on "Quit Process".
These three suggestions should work for most situations where you want a program to stop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With