omersk2
omersk2

Reputation: 79

How to run python script on background/as a process?

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

Answers (3)

Jaguar Ro
Jaguar Ro

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

TMagnetB
TMagnetB

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

James McPherson
James McPherson

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

Related Questions