#1
  1. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31

    Question Need help w/converting .py to .exe!


    I downloaded and installed Python and py2exe tonight in hopes to make a desktop application in Python instead of having to learn C++ AND Win32. I got my first GUI-based Python script to work using the IDLE, but I can't covert my script to an exe file using py2exe.

    Here's the script's source:
    Code:
    from wxPython.wx import * 
    
    class MyApp(wxApp): 
    	def OnInit(self): 
    		frame = wxFrame(NULL, -1, "Hello from wxPython")
    		frame.Show(true)
    		self.SetTopWindow(frame)
    		return true
    
    app = MyApp(0)
    app.MainLoop()
    And here's my setup file:
    Code:
    # setup.py
    from distutils.core import setup
    import py2exe
    
    setup(name="win",
          scripts=["win.py"],
    )
    But I get this error:
    Code:
    Traceback (most recent call last):
      File "D:\python\setup.py", line 6, in ?
        scripts=["win.py"],
      File "D:\python\lib\distutils\core.py", line 125, in setup
        raise SystemExit, \
    SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
    
    error: no commands supplied
    Help!! Please!!
    Last edited by marron79; February 14th, 2003 at 01:53 AM.
    Matt
  2. #2
  3. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    when you call the setup.py file make sure you call it like this:

    Code:
    python setup.py py2exe
    You cannot just run the setup.py file by itself. Try the above method and let me know if that works.
    Hartmann
    badice.com
  4. #3
  5. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    Yes, that is when I get the error I posted above. I tried loading it in the IDLE and the command line tool. Both produce errors.
    Matt
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0

    directory


    Ok, well im assuming your working on Windows

    this is what you had before -

    python setup.py py2exe


    this might sound kinda silly but i got me a few times, try putting the full path to setup.py. if its on ur decktop it should be -

    python C:\windows\desktop\setup.py py2exe

    (if your useing windows 98 or 95, NT, 2000 and xp have there desktop in different places i believe)


    Tytan
  8. #5
  9. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31

    Re: directory


    Originally posted by calorics
    this might sound kinda silly but i got me a few times, try putting the full path to setup.py. if its on ur decktop it should be -

    python C:\windows\desktop\setup.py py2exe

    (if your useing windows 98 or 95, NT, 2000 and xp have there desktop in different places i believe)
    I'm using Windows XP Pro. I will try using the full path, but I'm pretty sure it won't matter since I get the same error no matter what I put as the script name. Will give it a try, thanks!
    Matt
  10. #6
  11. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    I tried using the full path as seen in this screenshot. I also tried it using python d:\setup.py py2exe. Same error.
    Matt
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Originally posted by marron79
    I tried using the full path as seen in this screenshot. I also tried it using python d:\setup.py py2exe. Same error.
    Um, don't run it from within the python interpreter. Run it from the DOS prompt.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  14. #8
  15. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    Originally posted by Strike
    Um, don't run it from within the python interpreter. Run it from the DOS prompt.
    Duh! Why didn't I think of that?

    Now it says "python isn't recognized as a command," which is weird because I know Python is installed (it's in the Program Files folder and shows up in the add/remove programs list).
    Matt
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Originally posted by marron79
    Duh! Why didn't I think of that?

    Now it says "python isn't recognized as a command," which is weird because I know Python is installed (it's in the Program Files folder and shows up in the add/remove programs list).
    So provide the full path to your python exe.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  18. #10
  19. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    Originally posted by Strike
    So provide the full path to your python exe.
    Great! It works!! Any chance of getting ride of the ugly DOS Prompt windows in the back when the app loads? Thanks!
    Matt
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0

    pyw


    The .pyw (PythonWindow/less?) excentionis great for GUI apps, it simply runs the program without Python/DOS window. i dont know how this works in Py2exe but its worth a try.

    Tytan
  22. #12
  23. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31

    Re: pyw


    Originally posted by calorics
    The .pyw (PythonWindow/less?) excentionis great for GUI apps, it simply runs the program without Python/DOS window. i dont know how this works in Py2exe but its worth a try.

    Tytan
    How do I make those? Does the person opening a .pyw file need Python to run the app?
    Matt
  24. #13
  25. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    Thanks to a tip from an anonymous DevShed guest, I now know how to make Python scripts into .exe w/out the DOS window in the background! It's so simple, I can't believe I didn't try it before.

    python setup.py py2exe -w

    Yep, that's all you have to do...add a "w" argument on the end!
    Matt

IMN logo majestic logo threadwatch logo seochat tools logo