ps x |grep python|awk '{print $1}'|xargs kill

ps x: show all process of current user
grep python: to get process that has python in command line
awk '{print $1}': to get the related process pidxargs kill`: to kill the process
note: make sure you don’t kill other processes! do ps x |grep python first.
since I usually use the jupyter notebook, so I use grep ipykernel
 ps x |grep ipykernel|awk '{print $1}'|xargs kill

there should be an elegant way to kill the related process using only ps+awk