The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Need help w/py2exe please!
Discuss Need help w/py2exe please! in the Python Programming forum on Dev Shed. Need help w/py2exe please! Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 14th, 2003, 01:42 AM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
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!!
__________________
Matt
Last edited by marron79 : February 14th, 2003 at 01:53 AM.
|

February 14th, 2003, 05:11 PM
|
 |
chown python:users\ /world
|
|
Join Date: Jul 2000
Location: Texas Tech
Posts: 95
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
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.
|

February 14th, 2003, 10:24 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
|
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.
|

February 20th, 2003, 03:16 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 12
Time spent in forums: < 1 sec
Reputation 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
|

February 20th, 2003, 02:14 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
|
Re: directory
Quote: 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!
|

February 21st, 2003, 05:44 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
I tried using the full path as seen in this screenshot. I also tried it using python d:\setup.py py2exe. Same error. 
|

February 21st, 2003, 08:27 PM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
Quote: 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.
|

February 21st, 2003, 11:14 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
Quote: 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).
|

February 23rd, 2003, 01:04 PM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
Quote: 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.
|

February 23rd, 2003, 03:07 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
Quote: 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!
|

February 24th, 2003, 07:49 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 12
Time spent in forums: < 1 sec
Reputation 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
|

February 24th, 2003, 02:59 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
|
Re: pyw
Quote: 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?
|

February 25th, 2003, 06:02 PM
|
 |
Rut row Raggy!
|
|
Join Date: Jul 2001
Location: Tornado Alley
|
|
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! 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|