p_tasklist = subprocess.Popen('tasklist.exe /fo csv', stdout=subprocess.
    PIPE, universal_newlines=True)
pythons_tasklist = []
for p in csv.DictReader(p_tasklist.stdout):
    if p['Image Name'] == 'python.exe':
        pythons_tasklist.append(p)
How to detect if a process is running using Python on Win and MAC