import psutil as psutil
for proc in psutil.process_iter():
proc_name = proc.name()
if proc_name == 'chrome.exe':
print('chrome is running now.')`
When I run the above Python code that checks whether an application like Chrome is opened or not on a MacBook M1 after opening Chrome, it does not print the correct result (i.e. Chrome is running now.)
For macOS (it will be different on Windows):