Install & Compatibility
Where this runs
tested against v7.2.2.20260827 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
No direct imports from types-psutil
✓ Users import symbols from `psutil` (e.g., `from psutil import cpu_percent`) after installing `types-psutil` for type checking.
The `types-psutil` library provides type stubs for the `psutil` library, enabling static analysis tools like MyPy to check code using `psutil`. It does not contain any runtime code or symbols intended for direct import by users. Your runtime code should only import from `psutil`.
This quickstart demonstrates how to use the `psutil` library. By installing `types-psutil`, static type checkers will be able to provide accurate type hints and catch potential type-related errors in your `psutil` code. The example retrieves and displays information about the current running process.
import psutil
from typing import Dict, Any
def get_process_info(pid: int) -> Dict[str, Any]:
"""Gets basic info for a process by PID."""
try:
process = psutil.Process(pid)
return {
"pid": process.pid,
"name": process.name(),
"cpu_percent": process.cpu_percent(interval=0.1),
"memory_info_mb": process.memory_info().rss / (1024 * 1024) # MB
}
except psutil.NoSuchProcess:
return {"error": f"Process {pid} not found."}
except psutil.AccessDenied:
return {"error": f"Access denied for process {pid}."}
if __name__ == "__main__":
# Get info for current process
current_process_info = get_process_info(psutil.Process().pid)
print(f"Current process info: {current_process_info}")
# To leverage `types-psutil`, install it and run a type checker:
# pip install psutil types-psutil mypy
# mypy your_script.py
# MyPy will then correctly infer types for `process.name()`, `process.cpu_percent()`, etc.
Upgrade
Version history
7.2.2.20260827latest on PyPI · released Aug 27, 2026
Audit
Dependencies
psutilrequiredThis library provides typing stubs for the `psutil` library; `psutil` itself must be installed for runtime functionality and for type checking to be meaningful.