#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    18
    Rep Power
    0

    Smile Help with py2exe!!!!!!


    HI everyone i just started with python and install py2exe and did some search for threats on on it and how to used it. BUt i still dont understand how to make your script in a .exe

    I need help im only 15 but lookin to advance in python
    I need someone to give the easy step by step proccess to i can learn.

    I found steps on this site and other but stll dont get it. i get errors

    Thanks ya help guys
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    First make sure the program runs without using py2exe
    If it does then post both your program and the setup script you are using plus the error reports you get to this forum.

    Until we know what scripts you use and the errors you get we cant help!

    grimey
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    18
    Rep Power
    0
    my program is a simple electronics app
    here the script


    # THE OHM LAW

    print " Find voltage"
    print " E=I*R"

    current=input("What is your current;")

    resistance=input("what is your resistance:")

    I=current
    R=resistance




    from here i dont know what to do ......i know u have to make a setup script and then add a module that will build it i dont know . Can you help me pls i dont know what to do ,, i got a setup script the is a example here it is

    from distutils.core import setup
    import py2exe

    setup(
    # The first three parameters are not required, if at least a
    # 'version' is given, then a versioninfo resource is built from
    # them and added to the executables.
    version = "0.5.0",
    description = "py2exe sample script",
    name = "py2exe samples",

    # targets to build
    console = ["Ohms Law.py"]



    I change the console to my script , but wen i run iit give me this

    Traceback (most recent call last):
    File "D:\Python24\Lib\site-packages\py2exe\samples\simple\setup.py", line 33, in -toplevel-
    console = ["Ohms Law.py"],
    File "D:\Python24\lib\distutils\core.py", line 137, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
    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



    Thanks for your help
  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Please read the sticky messages about posting code to the forum.

    Traceback (most recent call last):
    File "D:\Python24\Lib\site-packages\py2exe\samples\simple\setup.py", line 33, in -toplevel-
    console = ["Ohms Law.py"],
    File "D:\Python24\lib\distutils\core.py", line 137, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
    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
    To run the setup.py script you posted (assuming it is complete on your machine - it isn't in your post) you must type:
    c:\python23\python setup.py py2exe
    This is why your code did not compile - setup is complaining that you did not supply it with a command


    I notice your program has a space in the file name - this is not good practice. I recommend you rename it to something like ohms_law.py. That way you don't have to know how the OS or a python module that processes the path will handle spaces.

    There is no need to use py2exe at all:
    c:\python23\python ohms_law.py


    grimey
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    18
    Rep Power
    0

    help


    sorry, but i m still havin problems,im confuse. do paste the setup script in my program in the end or at the beginning?or if not what do i have to do, im a rookie at this....can u show me and example and fix my app so i can turn it in a win32app..i need an example so i can learn.

    or can u give a step by step instructions pls.



    ty
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    17
    Rep Power
    0
    I was trying to figure this one out too and found some sample setup.py scripts that worked for me. I was using Boa Constructor so in the editor window I had to set my comandline parameters, go to File, Set Commandline Parameters and put py2exe in the text box and run your setup.py file.

    Mine looked like this:

    Code:
    from distutils.core import setup
    import py2exe
          
    setup(windows=["Ohms_law.py"],
           data_files=[("bitmaps",
               ["mylogo.bmp"])]
    )
    My setup.py file was in the same directory as the file I was working on. I changed the name to reflect your file.

    Hope this helps.
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Lets see what we can do here; what I've done is attached a zip archive containing a take off of your Ohms Law program and the setup file used to create the exe .

    To build the exe: extract the two files from the archive and run the setup.py file.
    Thats it; open the ./dist directory and run ohms.exe - it's really pretty simple, if you read the comments in setup.py I'm sure you'll get it .

    Enjoy,

    Mark.
    Attached Files
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    18
    Rep Power
    0
    Finally is WORK!!!!!!!wow nice work


    but i got one question. Why did you re edited my script. Cuase now i really dont understand and the new stuff that u added jajajaa . Is is neccesary for my future program or can i make program the way i made it the first teim?


    Thanks in advance
  16. #9
  17. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Pichingo2005,

    Mark has provided a simple and complete solution for you. Every command is in Python's documentation and will not take you long to look up and read.

    Study his solution and you will be able to answer your own question. Play with the code, make some minor changes and understand what happens.

    If you are really confused after studying and experimenting then ask about specific lines.

    Have fun.

    grim
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    18
    Rep Power
    0

    Smile


    Thanks guys for all your help, im finally gettin this and making other simple work


    thanks again

IMN logo majestic logo threadwatch logo seochat tools logo