psutil moduleThe psutil (Python system and process utilities) is a Python package that retrieves information on ongoing processes and system usage (CPU, memory, storage, network, and sensors). We mainly use it for system monitoring, profiling, restricting process resources, and process management.
The module can be installed via pip as follows:
pip install psutil
pids methodThe pids method returns a list of all the process IDs of running processes in the system. This method only returns the process IDs.
psutil.pids()
The method takes no parameters.
The pids method returns a list of all the process IDs of running processes in the system.
import psutilpids = psutil.pids()print("The pids of the processes running are as follows")print(pids)
psutil module.psutil.pids() method and print them to the console.