Reputation: 79
I want to run a python script as a process/in the background. I searched and found pythonw.exe
but when I do pythonw.exe name_of_my_script.py
nothing happened. Am I doing something wrong and/or how else would I run it in the background?
This is part of my code that do problem :
from selenium import webdriver
I will thank you for any help whatsoever.
note: With the help of the comments here, I understood that also python.exe running don't work and bring error - NameError: name 'PROTOCOL_TLS' is not defined ( even tough in normal running it doesn't have errors.
edit: i used http://pytoexe.com/ and i got exe file that work but the cmd console still exist ( mabye it because i use phantomjs ? ) click here
Upvotes: 0
Views: 2900
Reputation: 26
You can create your own exe by going to http://pytoexe.com . After that convert your script. Choose windows-based and convert it. You'll not have any problems after that. Hope that helps.
Upvotes: 1
Reputation: 35
By "I want to run a python script as a process/in the background," do you mean make the window not visible? if so, just save the script as .pyw instead of .py
Upvotes: 0
Reputation: 2556
I'd approach this by using threading
module, and use os.fork()
- but I'm not running Windows. I suggest having a look through Difference in behavior between os.fork and multiprocessing.Process for other OSes.
Upvotes: 0