Thread: how 2 py2exe

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

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    how 2 py2exe


    Dear all

    can someone show me how to use py2exe for the following code? complicated.

    here is the code
    Code:
    import random
    a=int(raw_input("Enter set(s)of random numbers (6 numbers a set): "))
    for x in range (0,a):
        for i in range(1,7):
            print "\n%5d" % (random.randrange(1,50)),
            if i%6==0:
                print
    Thanks
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11
    Yes looked at the site , tried it runs with out any error but can't find the exe file
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    The quick way to do this is to search your Python installation directory and documents folder.

    Its not easy to keep up with py2exe right now since i've used 3 versions over the last few years and in each one the rules have changed .

    There should be an option to tell py2exe where to put the file though - or there was at some point. You should be able to type 'help' after invoking py2exe for a full list of options.

    Hope this helps,

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

  8. #5
  9. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Assuming you are actually running the latest python version and have installed the latest py2exe program...

    Make sure the setup script is in the same directory as the script you want to make an executable. It will then make a dist sub-directory when it is run. The executable should be in that sub-directory.

    If you are having problems direct the script to a log file and post the log file here.

    python win_exe.py > logfile.txt

    Send the logfile and we might be able to help
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11
    This is what i did
    I keep all my .py in a folder under d:\pyth2, running python from c:\python23
    This is how i compiled
    c:\python23\python.exe d:\pyth2\lot.py
    It created a folder called dist and build in d:\pyth2 and copied _sre.pyd,library.zip,python23.dll,w9xpopen.exe

    setup.py
    Code:
    from distutils.core import setup
    import py2exe
    setup(name="lot",version="1.0",py_modules=["lot"])
    Code:
    import random
    a=int(raw_input("Enter set(s)of random numbers (6 numbers a set): "))
    for x in range (0,a):
        for i in range(1,7):
            print "\n%5d" % (random.randrange(1,50)),
            if i%6==0:
                print
    I don't know if it's right

    Thanks
  12. #7
  13. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    This works:

    I've modified your setup script in two ways:
    1. I've added the py2exe parameter so that you don't have to type it.
    2. I changed your setup to be in line with my script and the guidelines on the py2exe Wiki.

    Code:
    from distutils.core import setup
    import sys
    sys.argv.append("py2exe")
    import py2exe
    setup(console = [{"script": "lot.py", }], version = "1.0", py_modules = ["lot"])
    Grim
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11
    Hi Grims
    It works Thank you so much

IMN logo majestic logo threadwatch logo seochat tools logo