I'm trying to test if a browser is open on a python program converted to an exe with pyinstaller, Is there a way to test this without displaying a window and converting it to an exe?
I tried subprocess but it creates an error with the windowed mode of pyinstaller and I can't import psutil into pyinstaller ("can't import psutil" error)
The code I use with subprocess:
enter code heresubprocess.check_output('tasklist', shell=True)
The program does not start and an error message appears: "Failed to execute script" A similar error posted here: subprocess seems not working in pyinstaller exe file
Thank you in advance for your answers
If you just want to check whether a process running or not you can use
psutil.process_iterbut as Pyinstaller can't quite resolve thepsutilmodule you need to useadd-dataflag to add the whole Lib folder to your output executable:Next use below command to generate your executable (you can also use
-wflag as well):