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
1
vote
0 answers

Python's psutil doesn't report correct process status

I'm using the following code to check if a process is running: import time import psutil def isRunning(name): for process in psutil.process_iter(): if name in process.name() and process.status() == psutil.STATUS_RUNNING: …
Mircea Ispas
  • 20,260
  • 32
  • 123
  • 211
1
vote
0 answers

How to kill all background async process run through python?

I am initializing multiple asynchronous process which are running in the background to a python screen. Now, after initializing i am not able to kill all the of these background process by a keyboard interrupt or ctrl + c. I have found the method of…
1
vote
2 answers

How to get all processes to a string?

There is the following code, how to display all processes in it with one line and remove from each .exe? import psutil for proc in psutil.process_iter(): name = proc.name() print(name) to get it chrome, opera, svhost, ...
user12951028
1
vote
1 answer

Is there a way to make the psutil output consistent between runs?

I'm trying to get some data out of psutil. Specifically I want to get the memory_percentage and name data in this order. Here is the code: def getListProcessMem(): for proc in psutil.process_iter(attrs=None, ad_value=None): procInfo =…
Iverol
  • 39
  • 7
1
vote
1 answer

cpu-percent in psutil returns 0.0 for every process

I've been inspired to try to make a wordcloud wallpaper generator by a similar github project. I'm not much experienced and this seems like a good beginner-ish project. For now I'm trying to get some usable output out of psutil and it does seem to…
Iverol
  • 39
  • 7
1
vote
2 answers

Failure to install psutil on windows

I am trying to install psutil on windows 10 for python 3.4 I have done pip install psutil, however was met with a bunch of errors. I'm sorry I tried to copy console error messages however it would not let me, I hope that this will be sufficient for…
1
vote
1 answer

python psutil.cpu_count() returns wrong number of cpus

I used slurm to allocated 32 cpus. However, when I use cpu_count functions from psutil to get the number of available cpus, it returns only 16 cpus available. Why cpu_count returns less number than actual number of cpus?
Henry Bai
  • 367
  • 1
  • 3
  • 17
1
vote
2 answers

Detecting Available Network Adapters With Python

I want to detect the available network interfaces that is connected to a DHCP and got an IP from it. I am using following script to generate the list of available adapters. import psutil addrs = psutil.net_if_addrs() all_network_interfaces =…
I.K.
  • 414
  • 6
  • 18
1
vote
1 answer

Unable to import psutil in Python 3.7 (Import Error)

I am unable to import psutil when I activated python on my venv, its gives the following error message, which I cant resolve. I tried to uninstall psutil and install psutil again but it still returns the same error. >>> import psutil Traceback…
Rootie
  • 111
  • 1
  • 1
  • 8
1
vote
1 answer

psutil on Linux shows no CPU Core Temperatures

My Python 3 script uses psutil v5.6.2 to extract various information about the current system (Ubuntu 18.04, AMD Ryzen 2700X) such as the CPU core temperatures. Problem: However running the following code to obtain the core temperatures import…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
1
vote
0 answers

psutil.cpu_percent() showing 0.0 as script of from cmd-line but works as intended from interpreter

python -c "import psutil;print(psutil.cpu_percent())" Output: 0.0 python # we're in the interpreter now import psutil print(psutil.cpu_percent()) output: 12.7 what's going on here? when running it outside of the interpreter I always get either…
JackofSpades
  • 113
  • 1
  • 8
1
vote
0 answers

How do I load psutil.cpu_percent average for each process?

I'm trying to load the cpu averages for all process id's on a host using the following snippet of code: import psutil while True: for pid in psutil.pids(): p = psutil.Process(pid) cpu_p = float(p.cpu_percent()) if cpu_p…
hobbes
  • 467
  • 1
  • 7
  • 22
1
vote
1 answer

Python CPU and RAM memory usage

I am writing a script that writes CPU and RAM usage, I want to add list every process using 1% CPU or RAM import datetime ,psutil ,time ,subprocess mem_usage = (psutil.virtual_memory()) cpu_usage = psutil.cpu_percent(interval=1) cmd = "WMIC PROCESS…
1
vote
1 answer

Can't pip install psutil on Debian (Raspbian)

I am trying to install psutil on my Raspbian VM where I am working on the python code. Later I am planning to upload it to pi. Every time when I try to install psutil, it gives following error. pi@raspberry:~ $ pip3 install psutil Collecting…
deepjungle
  • 128
  • 8
1
vote
1 answer

Installation of psutil in virtualenv at Ubuntu16.04

What could be wrong with my installation? I am trying to install psutil in virtualenv at my Ubuntu16.04. Should be quite straightforward as pip3 install psutil. But I have error as Collecting psutil Using cached…
batuman
  • 7,066
  • 26
  • 107
  • 229