Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:42:02+00:00 2026-05-26T20:42:02+00:00

I am trying to find out a way to detect if a process is

  • 0

I am trying to find out a way to detect if a process is running in Windows Task Manager for Windows OS and Macintosh Activity Monitor for MAC OS using Python

Can someone please help me out with the code please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:42:02+00:00Added an answer on May 26, 2026 at 8:42 pm

    psutil is a cross-platform library that retrieves information about running processes and system utilization.

    import psutil
    
    pythons_psutil = []
    for p in psutil.process_iter():
        try:
            if p.name() == 'python.exe':
                pythons_psutil.append(p)
        except psutil.Error:
            pass
    
    >>> pythons_psutil
    [<psutil.Process(pid=16988, name='python.exe') at 25793424>]
    
    >>> print(*sorted(pythons_psutil[0].as_dict()), sep='\n')
    cmdline
    connections
    cpu_affinity
    cpu_percent
    cpu_times
    create_time
    cwd
    exe
    io_counters
    ionice
    memory_info
    memory_info_ex
    memory_maps
    memory_percent
    name
    nice
    num_ctx_switches
    num_handles
    num_threads
    open_files
    pid
    ppid
    status
    threads
    username
    
    >>> pythons_psutil[0].memory_info()
    pmem(rss=12304384, vms=8912896)
    

    In a stock Windows Python you can use subprocess and csv to parse the output of tasklist.exe:

    import subprocess
    import csv
    
    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)
    
    >>> print(*sorted(pythons_tasklist[0]), sep='\n')
    Image Name
    Mem Usage
    PID
    Session Name
    Session#
    
    >>> pythons_tasklist[0]['Mem Usage']
    '11,876 K'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find out if there is a way to detect the
I'm trying to find out if there is a way of using clickTag and
I'm trying to find out a way to know the index of a anchor
I'm trying to find out if there is any way to elevate a specific
I'm trying to find out the most efficient (best performance) way to check date
I'm trying to figure out a way to find out which files were affected
I am trying to find out if there is a more optimal way for
Hi I'm trying to find out if there is a way to set the
I'm trying to find out how much memory my own .Net server process is
I'm trying to find a way to detect when focus is changed to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.