Run a python script as an exe and run a new process from it

venutaurus539 at gmail.com venutaurus539 at gmail.com
Fri Feb 27 00:16:42 EST 2009


On Feb 26, 11:14 pm, "Paddy O'Loughlin" <patrick.olough... at gmail.com>
wrote:
> Try this as an outline:
> #### script1.py
> from subprocess import Popen
>
> if __name__ == '__main__':
>         scriptname = "script2.py"
>
>         Popen("python %s" % scriptname, shell=True)
>
>         print "I'm done"
>
> #### script2.py
> from time import sleep
>
> if __name__ == '__main__':
>     while (True):
>         print "waiting.."
>         sleep(2)
>
> ###########################
> If you install python using the Windows Installer (.exe), it should
> set up .py files to be opened by python when double-clicking on them.
> Alternatively, you can right-click on your .py file and go to "Open
> With..." then "choose program", then click "Browse...", you can Browse
> to the python executable, so Explorer will use it to open .py files
> when you double-click on them.
>
> As someone else mentioned there is also a py2exe program. Google it.
>
> 2009/2/26 venutaurus... at gmail.com <venutaurus... at gmail.com>:
>
>
>
> > Hello all,
> >           I've a strange requirement where I need to run a python
> > script just as we run an exe (by double clicking through windows
> > explorer or by typing the script name at command prompt). In that
> > process I should be able to execute another python script in such a
> > way that, the second script should continue running but the main one
> > should terminate without effecting the second one.
>
> >                    My requirement may be little confusing so please
> > get back if you didn't understand what I meant above.
>
> > Thank you,
> > Venu.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --
> "Ray, when someone asks you if you're a god, you say YES!"

Thanks for the reply,,
            I am trying to use the above application using psexec()in
command line.But it failed returning the error message

 exited with error code 255.

              But when I ran the application normally it worked
fine.Do I need to add anything to my python script(either the main one
or the script which is calling it) to make it work.

Thank you,
Venu Madhav.



More information about the Python-list mailing list