#16
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    Originally posted by netytan
    There are two ways that i know of to do this, 1 you could us the -w flag from the command line, something like..

    python setup.py py2exe -w

    2, give your python program a .pyw extension (abc.py becomes abc.pyw)

    Mark.
    1.What does "-w" do?Can it remove the command window?
    2.you mean change all .py files to .pyw?and run the command like "python setup.pyw py2exe -w?

    Thank you.
  2. #17
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Well, pyw files run without the console window, so if you have a Python GUI (or any other Python program) with .pyw extension it will run without the "command window".. you just write a normal setup.py file and point it at your pyw

    The -w flag will do exactly the same thing as the method above and works exactly the same way as normal, all you need to do is add -w to the end of your command

    Mark.
    programming language development: www.netytan.com Hula

  4. #18
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    Thanks a lot.
    I tried add a -w after my command.It worked,and removed the DOS windows.
  6. #19
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    I have a question :

    When you add the '-w' flag, it means you want to run your script with pythonw.exe. I tried this for a simple script and nothing happens when I launch my program (and it works when I build a console app). Do I need to add something in my script to run this way ?
  8. #20
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Running a console app with pythonw.exe wont show and console window because thats exactly what its designed to do, your program still runs as normal though! Which is great when you want to make programs which run in the background (out of sight)..

    Mark.
    programming language development: www.netytan.com Hula

  10. #21
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    Hummm... Sounds interesting. In fact it gave me an idea, but I have a problem :

    When I added the pickle module to my script, I got a warning message while compiling saying that some modules could not be found (readline, carbon...). Now my script works fine before I convert it to exe but it doesn't work anymore after I've done so... What can I do ?
  12. #22
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    mnot sure exactly what your doing but i see no reason why it doesn't work.. you could try using one of the 'Flags to include or exclude modules or packages' on Py2exe's homepage i.e.

    --includes or -i list
    comma separated list of modules to include. Note that includes overrides excludes.
    looks promising, give that a go, if it doesnt work then let me know and i'll run a few tests myself!

    Take care,
    Mark.
    programming language development: www.netytan.com Hula

  14. #23
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    ALRIGHT ! I did that and it worked... but I wasn't expecting it to work . Thanks !
  16. #24
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    Oh, I forgot... When I convert some script to exe, (leaving the console...), I get warning messages that I don't see when running my script on Python GUI (such as "Warning : integer exponentiation", and some others...) Can I remove those and if yes how ?

    Thanks in advance.
  18. #25
  19. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Mmmmmm, i've never head of this before and i can't find any docs on the p2exe website about this.. since warnings are not errors you cant really use the try statment on it (or i don't think so). I'll look into turning warnings off for you though and let you know what i find!

    Mark.
    programming language development: www.netytan.com Hula

  20. #26
  21. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok, there are two ways too do this from what i can see.. the first is by using the command line option -W arg which i havn't quite figured out yet! and the second (and my prefered) way if to use the warnings module i.e. import warnings; warnings.filterwarnings('ignore')

    Hope this helps,
    Mark.
    programming language development: www.netytan.com Hula

  22. #27
  23. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok, i got the -W thing down - got a little comfused there for a second or two - if your calling a Python program from the command line and you want to turn warnings off you can do something like this:

    python -W ignore path/to/python/program

    the ignore option can be changed to yeild different results depending. I know this wont help much with Py2exe but just incase anyone was interested.

    Mark.
    programming language development: www.netytan.com Hula

  24. #28
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    Great ! I tried the warnings module thing and it worked perfectly.

    Many thanks !
  26. #29
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Py2.exe to PY


    I have a different problem. I converted all my code from py to exe and then my system failed and then I found out that the system I had been using for my backups also failed. The only thing I have available to me is the exe file. So my problem now is how to convert the exe file back to py in the hopes of getting my source code back. Anyone have any ideas?
  28. #30
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0
    I need help for my file , to be executable..Can anyone help me ?

    <edited by Scorpions4ever>That file is a key-generator for certain Huawei routers. </edited>
    Last edited by Scorpions4ever; June 18th, 2012 at 01:35 AM.

IMN logo majestic logo threadwatch logo seochat tools logo