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
8
votes
1 answer

How to use psutil.Popen with unicode commands on Python 2

Hey I'm trying to execute the following command (using psutil.Popen with python 2.7): "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE" "C:\docs\ת.xlsm" Using this code: dir = u"C:\\docs" doc = os.listdir(dir)[0] full_path =…
Drxxd
  • 1,860
  • 14
  • 34
8
votes
1 answer

psutil: Measuring the cpu usage of a specific process

Im trying to measure the cpu usage of a process tree. Currently getting the cpu_usage of a process (without children) will do, but I'm getting weird results. import psutil p = psutil.Process(PID) p.cpu_percent gives me back float>100, how is that…
user1018517
8
votes
2 answers

python psutil psutil.get_process_list() error

Im trying to do some things with python psutil but get a strange error. procs = psutil.get_process_list() Gets me the following error: AttributeError: 'module' object has no attribute 'get_process_list' The only thing i found about it was…
Merijndk
  • 1,674
  • 3
  • 18
  • 35
7
votes
1 answer

Plotly.io doesn't see the psutil package even though it's installed

I'm trying to execute the following code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib %matplotlib inline import seaborn as sns import plotly.graph_objects as go from plotly.offline import…
Gigikalo
  • 191
  • 2
  • 6
7
votes
1 answer

Failed building wheel for psutil

I am trying to install psutil in centos and same is failing with gcc error . I have referred various posts in this forum but none of them helped . Many threads suggested to use pydev but its already there in my system #sudo /opt/airwave/bin/pip…
Sandeep Lade
  • 1,865
  • 2
  • 13
  • 23
7
votes
1 answer

Why is psutil.process_iter() running so slowly?

When I run the below code, it takes over two minutes to cycle through all the processes. Is this normal? I have been using psutil.process_iter() for a while, and I don't remember it taking this long before. import psutil import datetime as dt …
geronimo
  • 1,277
  • 1
  • 10
  • 11
7
votes
4 answers

Any pyinstaller detailed example about hidden import for psutil?

I want to compile my python code to binary by using pyinstaller, but the hidden import block me. For example, the following code import psutil and print the CPU count: # example.py import psutil print psutil.cpu_count() And I compile the code: $…
coanor
  • 3,746
  • 4
  • 50
  • 67
7
votes
0 answers

Python psutil memory does not match linux command

I want to know why psutil's virtual memory used or active do not match the value I get from the linux command 'free -m' What I want to know is the physical system memory used. virtual_memory().total / 1024 / 1024 = 29741 virtual_memory().used / 1024…
max
  • 9,708
  • 15
  • 89
  • 144
7
votes
1 answer

Memory usage of a single process with psutil in python (in byte)

How to get the amount of memory which has been used by a single process in windows platform with psutil library? (I dont want to have the percentage , I want to know the amount in bytes) We can use: psutil.virtual_memory().used To find the memory…
pafpaf
  • 275
  • 2
  • 5
  • 12
6
votes
1 answer

golang CPU usage

I am aware of [1]. With a few lines of code, I just want to extract the current CPU usage from the top n processes with the most CPU usages. More or less the top 5 rows of top. Using github.com/shirou/gopsutil/process this is straight-forward: //…
Patwie
  • 4,360
  • 1
  • 21
  • 41
6
votes
1 answer

Installing psutil library with pip on OSX for Python

I am new to python, and I have become interested in learning more about the efficiency of my functions. For example using generators vs. normal getter functions returning lists. I heard that you can measure the memory used by your python program by…
Varun Narayanan
  • 343
  • 6
  • 17
5
votes
2 answers

Unable to import psutil on M1 mac with miniforge: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

I'm using a miniforge environment on an M1 mac, and unable to import psutil: ImportError: dlopen(/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried:…
caspian_sea
  • 53
  • 1
  • 3
5
votes
1 answer

Requirement already satisfied with psutil

I´m trying to install the lib psutil, using the command !pip install psutil. When I run this code, I got this Requirement already satisfied: psutil in /opt/conda/lib/python3.6/site-packages (5.4.8) After that, I try to run this code: from…
Alberto Aguilera
  • 311
  • 1
  • 5
  • 13
5
votes
2 answers

How psutil.cpu_percent() function works?

I was executing the below two statements in python interpreter. >>> psutil.cpu_percent(interval=None, percpu=False) 2.0 >>> psutil.cpu_percent(interval=None, percpu=True) [1.5, 1.6, 3.7, 3.5] when percpu=False it is expected to give system-wide CPU…
user2076561
  • 139
  • 1
  • 2
  • 7
5
votes
0 answers

psutil hangs with a psutil.NoSuchProcess process no longer exists

Ive been messing with this but keep getting an error, Im assuming the pid is changing right before Im asking for the cpu_percent. Heres my little test program, it basically is opening a file waiting for the the program to finish loading close the…
scate636
  • 135
  • 2
  • 11
1
2
3
32 33