How to terminate process created by Python Popen
问题 I'm running calc.exe (windows 10, python 3.6) using proc = subprocess.Popen("calc.exe") , then time.sleep(time) and then want to kill process: os.kill(proc.pid, -9) or os.kill(proc.pid, signal.SIGTERM) gives me error "Access Denied". I also tried proc.terminate - it didn't help. And I also noticed that proc.pid gives different PID from PID which is shown in task manager. Any ideas how to kill my process? Thanks! 回答1: You can try using windows to kill the process. command = "Taskkill /IM calc