How can I stop a particular cell from running in google colab?

If you have a multi-cell file running and you need to stop a particular cell from running. Follow this:

A multicell notebook is running

Select the code from the google colab cell of interest.

Select the code

Use ctrl + x to cut the code from the cell (or copy). Delete the cell (this stops the code from executing).

Delete the cell

Now, create a new cell and paste the code you just copied.


Press the stop button, or select the 'Interrupt execution' item from the Runtime menu.

enter image description here

Keep in mind that some code cannot be interrupted. (For example, if you're using a C library stuck in a syscall.) In these cases, you can restart your Python process by selecting 'Restart runtime...' from the Runtime menu.