Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop python in terminal on mac

Tags:

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:

  1. Is there a short-key to really exit (not just stop) python in terminal? and, why

    ctrl-c

    does NOT work?

  2. How do I kill all the stopped python?

BTW, how could I type 'ctrl-c' and other hotkeys with a keyboard look?

Thanks!

like image 913
lukmac Avatar asked Aug 04 '13 21:08

lukmac


People also ask

How do I quit Python on Mac terminal?

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().

How do I stop a function in Terminal Mac?

In the Terminal app on your Mac, in the window running the shell process you want to quit, type exit , then press Return.


1 Answers

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.

like image 166
user2522001 Avatar answered Sep 22 '22 20:09

user2522001