|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
It does run b4 i compile in py2exe, but im stil gettin a syntax error. What actually is syntax?
|
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
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. |
|
#8
|
||||
|
||||
|
<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. |
|
#9
|
||||
|
||||
|
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?
|
|
#10
|
||||
|
||||
|
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 lolC:\Python23\python path\to\setup.py py2exe -d C:\ That should fix the <stdin> bit... if not i'm running outa ideas ![]() Mark. |
|
#11
|
||||
|
||||
|
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. |
|
#12
|
||||
|
||||
|
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. |
|
#13
|
||||
|
||||
|
Pretty much, yeh, and then display it in it's window. Il jus c if ur setup script helped...
|
|
#14
|
||||
|
||||
|
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 |
|
#15
|
||||
|