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 January 22nd, 2004, 09:23 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
Thumbs up Just started Python...

Ok i've written my program. It's called program1.py. Now what should I do for setup.py and then changin 2 an exe with py2exe?Does it matter what folder the files are in?Any help would be much appreciated. thank you.

Last edited by lucas : January 22nd, 2004 at 09:34 AM.

Reply With Quote
  #2  
Old January 22nd, 2004, 10:15 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Well i dunno what your program looks like but best case all you need in your setup.py file is...

Code:
from distutils.core import setup
import py2exe
      
setup(console=["myscript.py"])


Take a look at the distutils.core.setup in the Python docs for more info:

http://www.python.org/doc/current/d...tup-script.html

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


Reply With Quote
  #3  
Old January 22nd, 2004, 10:23 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
Ok tnx, but what would I do to run setup and where should the files be placed?Whenerver I type stuuf in the command, e.g. setup.py py2exe i get told that there is a syntax error: invalid syntax

Last edited by lucas : January 22nd, 2004 at 10:26 AM.

Reply With Quote
  #4  
Old January 22nd, 2004, 10:38 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Ah ok, does your program actually run before you try and compile with py2exe? Anyway the command line should look like this

python path/to/setup.py py2exe

After this you should have an .exe placed somewhere on your Python Path, i believe in the py2exe directory but i'm not 100%..

you can put you're files where you like . Another link you might be interested in:

http://starship.python.net/crew/theller/py2exe/

Mark.

Reply With Quote
  #5  
Old January 22nd, 2004, 10:49 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
It does run b4 i compile in py2exe, but im stil gettin a syntax error. What actually is syntax?

Reply With Quote
  #6  
Old January 22nd, 2004, 10:58 AM
darkleaf darkleaf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: netherlands
Posts: 51 darkleaf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I actually always used this:

(python path)/python setup.py py2exe

I think your exe file is in the folder dist now. If not you have to check the folders somewhere in ti you'll find a folder named your program. it's in there

Reply With Quote
  #7  
Old January 22nd, 2004, 03:57 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Mmmm ok, whats the best way to explain syntax... i guess, and sorry if this is hard to understand.

Syntax is like a set of rules you must obay when writing in a given language. Like grammer in english. Sentences begin with capitals and end in full strops.

A syntax error is generated when your code breaks the rules for whatever reason.

Hope that helps... so have you got it working now? If not can you attach the files your using. Might make it easier to track down the problem.

Mark.

Reply With Quote
  #8  
Old January 23rd, 2004, 03:50 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
<u>I think I got the setup script rite cos in turned the files into compiled python files, but I still havnt managed to change it into a .exe The code for the program1.py file is:</u>

Code:
a = ("Dan")
print "Halt!"
s = raw_input("Who goes there? ")
if s != a:
    print s,", get off this computer!"
if s == a: 
    print "You may pass,", s
d = raw_input("Where would you like to go?")
print "then go to" ,d, s

password = "foobar"

#note that != means not equal
while password != "learn":
    password = raw_input("Password:")
print "You have gained access to this program."
number = 56
guess = 0

while guess != number : 
    guess = input ("Guess a number: ")

    if guess > number :
        print "Too high"

    elif guess < number :
            print "Too low"

print "Just right"


<u>and the setup script is:</U>

Code:
#!/usr/bin/env python

from program1 import setup
import py2exe

setup(name="program1",
      version="1.0",
      description="Python Distribution Utilities",
      author="LuCaS",
      author_email="???@???.???",
      url="http://www.python.org/sigs/distutils-sig/",
     )


<u>Thanx 4 all ur help. I rly appreciate it!</u>

Last edited by netytan : January 23rd, 2004 at 09:17 AM.

Reply With Quote
  #9  
Old January 23rd, 2004, 06:18 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
I got another question as well. Say i wanted to write a program that downloads a text file off a website automatically whn it is opened and then displays it. How could I go about this?

Reply With Quote
  #10  
Old January 23rd, 2004, 07:45 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
OK, lets take another guess .. i'm thinking the last error you got was because setup.py isnt being found soooooo give this a go lol

C:\Python23\python path\to\setup.py py2exe -d C:\

That should fix the <stdin> bit... if not i'm running outa ideas

Mark.

Reply With Quote
  #11  
Old January 23rd, 2004, 07:49 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Ok, lets take another stab at this , try this one...

C:\Python23\python path\to\setup.py py2exe -d C:\

The <stdin> bit seems to be because setup.py couldn't be found... at the least that should be fixed *crosses fingers*

Mark.

Reply With Quote
  #12  
Old January 23rd, 2004, 10:59 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
A big part of whats wrong here could be the first line in your setup.py file . Just tried compiling your program myself and it ran without any problems... soooo.

Code:
setup.py
from distutils.core import setup
import py2exe
      
setup(console=["program1.py"])


Give that a go...

Mmm, what exactly do you want it to do? Just download a text file at a given URL weh the program is run?

Mark.

Reply With Quote
  #13  
Old January 23rd, 2004, 11:02 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
Pretty much, yeh, and then display it in it's window. Il jus c if ur setup script helped...

Reply With Quote
  #14  
Old January 23rd, 2004, 11:10 AM
lucas's Avatar
lucas lucas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 367 lucas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 30 sec
Reputation Power: 5
Ok i tryed that script and ran it in the shell to see what happened and this was the error i got:


Traceback (most recent call last):
File "C:\Python23\setup.py", line 1, in -toplevel-
setup.py
NameError: name 'setup' is not defined

the path to python/ where the .py files are is C:\Python23

Reply With Quote
  #15  
Old January 23rd, 2004, 11:19 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529