Questions tagged [psutil]

psutil (python system and process utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network) in Python.

psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network) in Python. It is useful mainly for system monitoring, profiling and limiting process resources and management of running processes. It implements many functionalities offered by command line tools such as: ps, top, lsof, netstat, ifconfig, who, df, kill, free, nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It currently supports Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures, with Python versions from 2.6 to 3.5.

Resources:

481 questions
2
votes
1 answer

ImportError cannot import name _common(Python 3.4)

I am using Python 3.4 and I just installed psutil. When I import this module using import psutil in the shell I get the following error: Traceback (most recent call last): File "", line 1, in import psutil File…
Ivar de Bruin
  • 121
  • 1
  • 4
2
votes
1 answer

Return number of CPU sockets, Cores, and Threads in Golang

Using Golang I'm trying to find/write a function that would return the number of CPU Sockets, Cores per socket, and Threads per core a Linux system. For example, a server might have 2 CPUs each with 4 cores, with hyperthreading, it could handle 8…
tbenz9
  • 446
  • 2
  • 5
  • 18
2
votes
4 answers

Python detect a python script's name in the list of processes

I know I can use psutil to get a list of running processes' names like this import psutil for i in psutil.pids(): print(psutil.Process(i).name()) However, If i run a python script with python, psutil only will show me that I have an instance…
GriMel
  • 2,272
  • 5
  • 22
  • 40
2
votes
0 answers

How to Profile a certain function in Python

I have written a command line based application and want to profile every module when it runs. It is a single threaded application , and the modules are function calls which do something. I need to measure things like Time taken by the function,…
Shaurya Chaudhuri
  • 3,772
  • 6
  • 28
  • 58
2
votes
2 answers

psutil without C extensions

I'm considering using psutil for CPU and Volumes monitoring. However, for my project it would be ideal if I could somehow get rid of the C extensions psutil uses: I want my project to be as self-contained as possible with no need for compilation on…
vladosaurus
  • 1,638
  • 1
  • 13
  • 18
2
votes
1 answer

Tuple looks confusing when returning psutil's functions

I am new to Python and trying things out with psutil. After I get the IO counters from the function , it says that it returns a tuple but then why the returned result looks more like a dictionary ? I can get the data extracted as tuples but whats…
Fenomatik
  • 457
  • 2
  • 8
  • 22
2
votes
3 answers

Python: Creating a Loop to update data

I have a small python script this is printing out how much CPU usage the machine is using, I am running into an issue, that it won't update after there is a change in percentage, I put it under an infinite while loop but it stays at the last percent…
octain
  • 964
  • 3
  • 10
  • 24
2
votes
1 answer

Find the path of every running process in Python

I want to find the path of every running process in windows. I tried to use the psutil module but it doesn't show me all the paths. It can't find many processes' paths because of the error: "psutil.AccessDenied" c = wmi.WMI() for process in…
Hila
  • 189
  • 1
  • 13
2
votes
1 answer

CPU percent of running process

I'm trying to get the percent of CPU usage for an external process in python. I've seen some other posts on this topic, but haven't helped me too much. When I run the following function I get values that aren't consistent with what I'm seeing in…
ChrisD
  • 674
  • 6
  • 15
2
votes
2 answers

psutil/subprocess return code when process killed

I replaced some use of Python subprocess.Popen instances with psutil.Popen instances and expected the behaviour to remain the same. The psutil docs for Popen state: A more convenient interface to stdlib subprocess.Popen. It starts a sub process and…
Brian O'Kennedy
  • 1,721
  • 1
  • 13
  • 18
2
votes
1 answer

How do I know if a file has been closed if I open it using subprocess.Popen?

I am opening files using the following commands in python : file = os.path.normpath(file_path) phandler = subprocess.Popen(['open', '-W', file]) I am polling is_opened = phandler.poll() == None to see if the process has been terminated. It is…
Pradeep Vairamani
  • 4,004
  • 3
  • 36
  • 59
2
votes
3 answers

Find if process is running in Windows psutil

process_name = "CCC.exe" for proc in psutil.process_iter(): if proc.name == process_name: print ("have") else: print ("Dont have") I know for the fact that CCC.exe is running. I tried this code with both 2.7 and 3.4…
KAKAK
  • 879
  • 7
  • 16
  • 32
2
votes
2 answers

Python 3.4 Installing psutil on Windows 7 x64

I'm trying to install from source psutil 2.1.0 for Python 3.4. My OS is Windows 7 x64. I receive the error: c:\Python34\psutil-2.1.0>python setup.py install --verbose running install running bdist_egg running egg_info writing top-level names to…
delned
  • 125
  • 2
  • 10
1
vote
1 answer

Why doesn't psutil accurately represent available memory after deleting a class instance in Python?

I'm currently struggling to find out how much memory I actually have left on my device after I have deleted an instance of a class. I have tried to use the library psutil but it doesn't correctly show the memory I actually have available. In…
JosephM
  • 13
  • 4
1
vote
1 answer

How to make a window scroll when the turtle hits the edge

I made this Python program that uses psutil and turtle to graph a computer's CPU usage, real time. My problem is, when the turtle hits the edge of the window it keeps going, out of view - but I want to make the window scroll right, so the turtle…
Kovy Jacob
  • 489
  • 2
  • 16