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

    Join Date
    Nov 2004
    Posts
    35
    Rep Power
    11

    another dude wants help in py2exe


    hey help please i tried doing what other posts said but i cant
    here is my code
    its in spanish.
    i can translate to english if you need
    i want an exe please buddies

    Code:
    # Computadora adivina tu numero 1.0.17
    #
    #Hay que buscar una forma que no se cierre cuando el input es de letras
    #Pero es un Bug menor
    #
    # By IvanHope
    # Nov 7 2004
    
    print "Piensa un Numero del uno al 10 y la computadora te lo va a tratar de adivinar..."
    print "Cada vez que la computadora te diga un numero tenes que contestar"
    print """
    	[1] - Correcto
    	[2] - Mas grande
    	[3] - Mas chico
    """
    
    print "\n\n\tPresiona enter cuando estes listo"
    raw_input("...")
    import random
    res = 0
    temp = 0
    while res != 1:
    	#Esta opcion solo exite la primera vez
    	if res == 0:
    		guess = random.randrange(10) + 1
    	#Si el usuario quiere un numero mas grande se ejecuta esta accion
    	elif res == 2:
    		guess = random.randrange(10) + 1
    		while guess < temp:
    			guess = random.randrange(10) + 1
    	#Si el usuario quiere un numero mas chico se ejecuta esta accion
    	elif res == 3:
    		guess = random.randrange(10) + 1
    		while guess > temp:
    			guess = random.randrange(10) + 1
    	#Esta no hace falta pero la puse por las dudas que halla algun error y para poder usar "else"
    	elif res == 1:
    		print "QUE COMPUU GROSA QUE SOY AHHHHH???"
    	#Esto hace que el programa empiece con la funcion original si el usuario no responde ninguna opcion
    	else:
    		guess = random.randrange(10) + 1
    		
    	temp = guess
    	print "\n\n\tEs tu numero el: ", guess, "?"
    	print """
    		[1] - Correcto
    		[2] - Mas grande
    		[3] - Mas chico
    	"""
    	res = int(raw_input("Elige una opcion: ?"))
    	if res == 1:
    		print "QUE COMPUU GROSA QUE SOY AHHHHH???"
    	elif res == 2:
    		guess = random.randrange(10) + 1
    		while guess < temp:
    			guess = random.randrange(10) + 1
    		temp = guess
    	elif res == 3:
    		guess = random.randrange(10) + 1
    		while guess > temp:
    			guess = random.randrange(10) + 1
    		temp = guess
    	else:
    		print "RESPUESTA EQUIVOCADA, LEE IDIOTA!!! - Es 1, 2 o 3"
    		raw_input("Enter para continuar")
    
    raw_input("\n\n\tPresione ENTER para salir...")
    Last edited by Scorpions4ever; August 3rd, 2007 at 05:34 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    35
    Rep Power
    11
    i am using this scriipt to do the exes

    Code:
    """
    makeExe.py
    - Simple Python script to automate the creation
      of Python executables using py2exe.
    
    (c) 2004 Premshree Pillai (24/01/04)
    http://www.qiksearch.com/
    """
    
    ## Run this file from Python root dir
    
    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
    this are the files i get:

    *_sre.pyd
    *library.zip
    *python23.dll
    *w9xpopen.exe


    http://img117.exs.cx/my.php?loc=img117&image=shot.jpg

    WHERE IS MY EXE???
    i cant find it
  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Do you have the a log of the output that is produced by this script?

    c:\python23\python makeExe.py > makelog.txt
    will do this.

    grim

IMN logo majestic logo threadwatch logo seochat tools logo