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

    Join Date
    May 2004
    Posts
    10
    Rep Power
    0

    .Py to .exe (sorry i know this has been answered again and again)


    Umm, hi? I'm like REALLY new to python (like 2 days) and i cant get my .py into .exe with py2exe. I have all the components needed to make it, i think.
    Here's my setup.py:

    Code:
    from distutils.core import setup
    import py2exe
    setup(console=["myscript.py"])
    thx if u can help,
    Dane
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    The only thing that comes to mind right now is that Py2exe can't find the program... so... you should check that your program is really called 'myscript.py', and that its in the same directory as 'setup.py'. If its not just to edit your setup file apropriatly nd give it another go

    Hope this helps,

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

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

    Join Date
    May 2004
    Posts
    10
    Rep Power
    0
    Well, i got a code:

    Code:
    import sys
    import re
    
    #function getFileName()
    def getFileName():
    	global fileName
    	fileName = raw_input("Enter file name (rel or abs path, eg., python/file.py): ")
    	try:
    		fp = open(fileName)
    		fp.close()
    	except IOError:
    		print "File does not exist!"
    		getFileName()
    
    #call function
    getFileName()
    
    
    package = re.split(":",fileName)
    package = re.split("/",package[len(package) - 1])
    package = re.split(".py",package[len(package) - 1])
    package = package[0]
    
    def getSetupName():
    	global setupName
    	setupName = raw_input("Enter name of setup file (or <enter> for default): ")
    	if(setupName == ''):
    		setupName = "setup.py"
    	try:
    		fp = open(setupName)
    		fp.close()
    		flag = raw_input("Setup file exists! Rewrite (0=no; else <enter>)? ")
    		if(flag == "1"):
    			getSetupName()
    	except IOError:
    		setupName = setupName
    
    getSetupName()
    
    fp = open(setupName,"w")
    temp = """from distutils.core import setup
    import py2exe
    setup(name = "%s",
         scripts = ["%s"],
    )""" % (package,fileName)
    fp.write(temp)
    fp.close()
    
    sys.argv.append("py2exe")
    execfile(setupName)
    
    fp = open(setupName,"w")
    temp = ""
    fp.write(temp)
    fp.close()
    
    print "\n", "Executable created!"
    print "Press <enter> to exit..."
    if(raw_input()):
    	exit
    its asks me what file and what setup and it works, (i think) but i cant find the .exe. it has all the files that should be there in dist but the exe is replaced by a blank "setup.py"
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Try looking in the Py2exe directory . I think thats the default localtion for the .exe files anyway.

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

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

    Join Date
    May 2004
    Posts
    10
    Rep Power
    0
    c:\python23\lib\site-packages\py2exe doesnt have it either...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    10
    Rep Power
    0
    in the dist folder, the .exe doesnt show up, but it just copies my setup.py and puts it in there! grrr
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Try doing a system wide search for your_python_programs_name.exe and see what comes up. If your on XP you should check out your user folder.

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

  14. #8
  15. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    You should find there is a dist sub-directory in the directory where you ran the setup.py script. If py2exe ran without a problem that is where your .exe is.

    Grim

IMN logo majestic logo threadwatch logo seochat tools logo