Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 14th, 2003, 01:42 AM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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!!
__________________
Matt

Last edited by marron79 : February 14th, 2003 at 01:53 AM.

Reply With Quote
  #2  
Old February 14th, 2003, 05:11 PM
Hartmann's Avatar
Hartmann Hartmann is offline
chown python:users\ /world
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Texas Tech
Posts: 95 Hartmann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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

Reply With Quote
  #3  
Old February 14th, 2003, 10:24 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old February 20th, 2003, 03:16 AM
calorics calorics is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 12 calorics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #5  
Old February 20th, 2003, 02:14 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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!

Reply With Quote
  #6  
Old February 21st, 2003, 05:44 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
I tried using the full path as seen in this screenshot. I also tried it using python d:\setup.py py2exe. Same error.

Reply With Quote
  #7  
Old February 21st, 2003, 08:27 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
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.
__________________
Debian - because life's too short for worrying.
Best. (Python.) IRC bot. ever.

Reply With Quote
  #8  
Old February 21st, 2003, 11:14 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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).

Reply With Quote
  #9  
Old February 23rd, 2003, 01:04 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
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.

Reply With Quote
  #10  
Old February 23rd, 2003, 03:07 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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!

Reply With Quote
  #11  
Old February 24th, 2003, 07:49 AM
calorics calorics is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 12 calorics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #12  
Old February 24th, 2003, 02:59 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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?

Reply With Quote
  #13  
Old February 25th, 2003, 06:02 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Need help w/py2exe please!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums