Registry / type-stubs / types-psutil

types-psutil

JSON →
library7.2.2.20260827pypypi✓ verified 26d ago

The `types-psutil` package provides PEP 561-compliant typing stubs for the `psutil` library, enabling static type checkers like MyPy and Pyright to analyze code that uses `psutil` for system and process utilities. As part of the typeshed project, its release cadence is tied to typeshed's updates and the `psutil` library's own releases, ensuring up-to-date type coverage. The current version is 7.2.2.20260408.

pip install types-psutil
INSTALL
IMPORT
SIG · TYPES-PSUTIL
T
types-psutil
type-stubspythonv7.2.2.20260827
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.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.
Debug
Known issues
gotchaThe `types-psutil` library provides type hints for the `psutil` library but does not install `psutil` itself. For your code to run and for type checking to be effective, `psutil` must also be explicitly installed in your environment.
fix
Ensure both `psutil` and `types-psutil` are installed: `pip install psutil types-psutil`
affects: All versions
gotchaAs `types-psutil` is part of `typeshed`, its versioning includes a date component (e.g., `7.2.2.20260408`). While it generally tracks the `psutil` version it provides stubs for, it's possible for there to be a mismatch. Ensure the `psutil` version you are using is compatible with the installed `types-psutil` stubs to avoid partial or incorrect type coverage, especially with very new `psutil` releases.
fix
Refer to the `typeshed` repository or `psutil` documentation for compatibility notes. Upgrade `types-psutil` regularly to match your `psutil` version.
affects: All versions
gotchaTyping stubs like `types-psutil` are purely for static analysis tools (e.g., MyPy, Pyright). They do not add any runtime functionality or modify the behavior of `psutil`. Do not attempt to import symbols directly from `types_psutil` or expect it to change runtime behavior; it only influences how type checkers interpret your `psutil` usage.
fix
Only import symbols from the actual `psutil` library in your runtime code. `types-psutil` is installed to aid your static analysis tools, not for runtime imports.
affects: All versions
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.
Agent activity
39 hits · last 30 days
node
32
OpenAI (training)
3
Resources
types-psutil — pip install types-psutil · libregistry