run exe and create exe

Discussion in 'Python' started by daved170, Oct 11, 2009.

  1. daved170

    daved170 Guest

    Hi everybody,
    I have 2 questions:
    1) I created my python application. It has QT Gui. How can I make exe
    of it? I don't want everytime I run the file it'll open the command
    line window which does nothing.

    2) My Application suppose to be a client server app. Anyhow, for now
    It's running only on local host. I added a button that run the server
    file.
    my server file located at "c:\temp\server.py". It takes no arguments.

    I tried the following codes at the push button function:

    os.system(""c:\temp\server.py"") - It stuck my GUI. I guess that this
    function doesn't open a new proccess.

    I also tried :
    os.spawnv(os.P_NOWAIT,"c:\temp\server.py");

    It raised the following error:
    OSError: [Errno 8] Exec format error.

    Any Idea what to do?

    Thanks
    DaveD
     
    daved170, Oct 11, 2009
    #1
    1. Advertising

  2. daved170

    r Guest

    On Oct 11, 10:15 am, daved170 <> wrote:
    > Hi everybody,
    > I have 2 questions:
    > 1) I created my python application. It has QT Gui. How can I make exe
    > of it? I don't want everytime I run the file it'll open the command
    > line window which does nothing.


    If you want to run your script without the command line popping up...

    1. rename the script to myscript.pyw
    *OR*
    2. run the script by C:\\PYVER\\pythonw.exe myscript.py


    if you want an exe check out py2exe... Google knows where to find it.
     
    r, Oct 11, 2009
    #2
    1. Advertising

  3. daved170

    MRAB Guest

    daved170 wrote:
    > Hi everybody,
    > I have 2 questions:
    > 1) I created my python application. It has QT Gui. How can I make exe
    > of it? I don't want everytime I run the file it'll open the command
    > line window which does nothing.
    >
    > 2) My Application suppose to be a client server app. Anyhow, for now
    > It's running only on local host. I added a button that run the server
    > file.
    > my server file located at "c:\temp\server.py". It takes no arguments.
    >
    > I tried the following codes at the push button function:
    >
    > os.system(""c:\temp\server.py"") - It stuck my GUI. I guess that this
    > function doesn't open a new proccess.
    >

    "" is an empty string, so ""c:\temp\server.py"" is just the empty string
    "" followed by c:\temp\server.py and then another empty string "".

    > I also tried :
    > os.spawnv(os.P_NOWAIT,"c:\temp\server.py");
    >
    > It raised the following error:
    > OSError: [Errno 8] Exec format error.
    >
    > Any Idea what to do?
    >

    A backslash starts an escape sequence, which you don't want because it's
    a path. You should either double the backslashes:

    os.spawnv(os.P_NOWAIT, "c:\\temp\\server.py")

    or use a raw string:

    os.spawnv(os.P_NOWAIT, r"c:\temp\server.py")
     
    MRAB, Oct 11, 2009
    #3
  4. On Sun, Oct 11, 2009 at 11:15 AM, daved170 <> wrote:
    >
    > Hi everybody,
    > I have 2 questions:
    > 1) I created my python application. It has QT Gui. How can I make exe
    > of it? I don't want everytime I run the file it'll open the command
    > line window which does nothing.
    >


    Two things about this.. One, if you want to "freeze" your app (turn it
    into a finalized exe binary that doesn't require you to have Python or
    QT installed), use py2exe. The problem with this is that your final
    binary will include the Python interpreter, QT, and any other modules
    you use so it will be pretty big.

    The other thing you can do is run the script with pythonw.exe instead
    of python.exe. It will still be a Python script, but it will run
    without opening a command prompt.
    >
    > 2) My Application suppose to be a client server app. Anyhow, for now
    > It's running only on local host. I added a button that run the server
    > file.
    > my server file located at "c:\temp\server.py". It takes no arguments.
    >
    > I tried the following codes at the push button function:
    >
    > os.system(""c:\temp\server.py"") - It stuck my GUI. I guess that this
    > function doesn't open a new proccess.
    >


    It does open a new process. But the new process is a child process of
    your original script and the first script will wait for it to finish
    so that it can get the return code.

    > I also tried :
    > os.spawnv(os.P_NOWAIT,"c:\temp\server.py");
    >
    > It raised the following error:
    > OSError: [Errno 8] Exec format error.
    >
    > Any Idea what to do?
    >

    In a normal string, \t = tab, so you're actually running the file
    "C: emp\server.py" which doesn't exist. Try using a raw string, double
    your backslashes, or use forward slashes instead.

    > Thanks
    > DaveD
    > --
    > http://mail.python.org/mailman/listinfo/python-list
     
    Benjamin Kaplan, Oct 11, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Duhhhhhhh

    Run and EXE.

    Duhhhhhhh, Sep 5, 2003, in forum: HTML
    Replies:
    2
    Views:
    490
    Thomas Jollans
    Sep 5, 2003
  2. Replies:
    2
    Views:
    3,278
  3. Replies:
    2
    Views:
    359
    Marcus Kwok
    Apr 24, 2006
  4. Metalone
    Replies:
    5
    Views:
    294
    Thomas Heller
    Oct 19, 2007
  5. Replies:
    9
    Views:
    1,026
    Paddy O'Loughlin
    Feb 27, 2009
Loading...

Share This Page