Hola a todos/as
He terminado un juego en Python y ahora quiero convertirlo en .exe para correrlo en otros SS.OO (Windows, Linux, Mac...)
Utilice py2exe y realice todo el proceso que hay que hacer hasta crear la carpeta dist, pero cuando abro la carpeta y ejecuto el .exe, me sale un flash rapidísimo con una pantalla negra.
Lo que he utilizado
python 2.3 (Programa de Python)
pythong (IDE donde cree el juego)
py2exe (Convertidor a exe)
Alguien que sepa, me podría decir cual es el motivo por el cual no se me ejecuta el .exe
Ahh: y ya utilice el raw_input al final de las lineas del programa y no se ejecuta tampoco.
Un saludo y agradezco la ayuda
Cita de: Tuplado en 1 Agosto 2013, 20:30 PMAlguien que sepa, me podría decir cual es el motivo por el cual no se me ejecuta el .exe
Pues hombre, teniendo en cuenta que py2exe es una utilidad obsoleta ya que la última actualización del programa es del año 2008... segúramente sea un problema de compatibilidad, y más si estás usando py 3.X, no eres el único que tiene problemas con py2exe ni serás el último...
...Por eso te digo lo mismo que le he dicho a todo el mundo respecto a compilar en Python, olvida esa mierd@ de py2exe y prueba a utilizar -> cx-freeze (http://cx-freeze.sourceforge.net) <-
Cuéntanos si te funcionó :),
un saludo!
hola EleKtro H@cker
Vale lo voy a descargar, pero sera compatible con Python 2.3, porque aquí la versión más vieja es 2.6, y no se si habrá problemas de compatibilidad.
Como sería el proceso con este programa para hacerlo .exe, si no es mucha molestia me podrías decir o remitirme a alguna pagina que me lo expliquen.
Gracias
Cita de: Tuplado en 1 Agosto 2013, 20:53 PMpero sera compatible con Python 2.3
No puedo asegurartelo, solo lo he probado con py 2.7 y 3
En la misma página que te pasé tienes la documentación: http://cx-freeze.readthedocs.org/en/latest/script.html#script
Citarcxfreeze hello.py --target-dir dist
Citar--include-modules=NAMES
comma separated list of modules to include
Gracias EleKtro H@cker, voy a probar con lo que me has facilitado.
Un saludo
I use Py2Exe
Citarahora quiero convertirlo en .exe para correrlo en otros SS.OO (Windows, Linux, Mac...)
Python sí es multiplataforma ya que Linux y Mac lo suelen traer instalado por defecto, en cambio los .exe solo los puedes ejecutar en un emulador en los otros S.O. y esto suele dar problemas.
Ten eso en cuenta si quieres usar el juego en otros sistemas operativos.
Un saludo.
Hola EleKtro H@cker y GingerCat:
Mira hice lo que me dijistes, pero lo compile con cx_Free, parecido a py2exe
Me crea el .exe con windows en una carpeta llamada build
pero cuando abro el ejecutable desde la consola me lanza este fallo:
File "C:\Python26\Lib\site-packages\cx_Freeze\initscripts\Console.py" , line 27
, in <module>
exec code in m.__dict__
File "menu_libro_blanco.py", line 9, in <module>
File "C:\Python26\modulepythong.py", line 844, in <module>
f=open(filename, "r")
IOError: [Errno 2] No such file or directory: "C:\\Python26\\build\\exe.win32-2.6
\\menu_libro_blanco"
Te facilito los 2 archivos el juego y el setup.py
JUEGO (menu_libro_blanco)
# MENU JUEGO
# ==========
# Importamos libreria de tiempo
import time
# Importamos todas las funciones del modulo (modulepythong)
from modulepythong import *
# Importamos todo el modulo random
import random
window_coordinates(0, 0, 400, 400) # GENERAMOS RESOLUCION
window_style("The Spaceship Game","black","TODO") # FONDO DE COLOR BLANCO
#-----------------------------------------------------------------------#
create_text(200,350,"The Spaceship Game",13.5,"CENTER","blue")
create_text(200,300,"_Easy level (E)",10,"CENTER")
create_text(200,250,"_Medium level (M)",10,"CENTER")
create_text(200,200,"_Hard level (H)",10,"CENTER")
create_text(200,150,"_Exit(X)",10,"CENTER")
#-----------------------NIVELES DE JUEGO--------------------------#
a = str("j")
while a != "x":
window_style('The Spaceship Game','black','TODO') # FONDO DE COLOR BLANCO
create_text(200,350,"The Spaceship Game",13.5,"CENTER","blue")
create_text(200,300,"_Easy level (E)",10,"CENTER","white")
create_text(200,250,"_Medium level (M)",10,"CENTER","white")
create_text(200,200,"_Hard level (H)",10,"CENTER","white")
create_text(200,150,"_Exit(X)",10,"CENTER","white")
#--NIVEL FACIL--#
if keypressed(2) == str("e"):
print "Nivel facil"
import time
from modulepythong import *
from math import sin, cos, pi
window_style('The Spaceship Game','white','TODO') # FONDO DE COLOR BLANCO
# Paisaje
altura_paisaje = 400
anchura_paisaje = 400
window_coordinates(0, 0, anchura_paisaje, altura_paisaje)
# Gravedad
g = 0.00001
# Nave
tamanyo_nave = 10
x = anchura_paisaje / 2
y = altura_paisaje - 100
vy = 0
impulso_y = 2*g
impulso_x = 0.00001
vx = 0
nave = create_filled_rectangle(x, y, x+tamanyo_nave, y+tamanyo_nave, 'blue')
# Plataforma
px = anchura_paisaje / 2
py = 0
vpx = .05
anchura_plataforma = 40
altura_plataforma = 3
plataforma = create_rectangle(px, py,px+anchura_plataforma, py+altura_plataforma, 'red')
# Tanque de combustible
color = "green" # combustible lleno
fuel = 1000
consumo = 0.1
rect_inicio = create_rectangle(0,altura_paisaje, 10, altura_paisaje-100, 'black')
lleno = create_filled_rectangle(1,altura_paisaje, 9, altura_paisaje-fuel/10, color)
create_text(25, altura_paisaje-8, '0%', 10, 'W')
create_text(30, altura_paisaje-95, '100%', 10, 'W')
# Dial de velocidad
circulo = create_circle(anchura_paisaje-50, altura_paisaje-50, 50, 'black')
for i in range(0, 360, 10):
create_line(anchura_paisaje-50 + 40 * sin(i*pi/180), \
altura_paisaje-50 + 40 * cos(i*pi/180), \
anchura_paisaje-50 + 50 * sin(i*pi/180), \
altura_paisaje-50 + 50 * cos(i*pi/180),)
if i % 30 == 0:
create_text(anchura_paisaje-50 + 30 * sin(i*pi/180), \
altura_paisaje-50 + 30 * cos(i*pi/180), str(i), 5, 'CENTER')
aguja = create_line(anchura_paisaje-50, altura_paisaje-50, \
anchura_paisaje-50 + 50 * sin(0*pi/180), \
altura_paisaje-50 + 50 * cos(0*pi/180),"black")
facil = create_text(200,200,"Level Easy",12,"CENTER","blue")
time.sleep(2)
erase(facil)
# Simulacion
while y > 0 and y < altura_paisaje and x > 0 and x < anchura_paisaje - tamanyo_nave:
vy -= g
if keypressed(1) == 'Up' and fuel > 0:
vy += impulso_y
fuel -= consumo
if fuel < 350:
color = "red" # combustible vaciandose
elif keypressed(1) == 'Left' and fuel > 0:
vx -= impulso_x
fuel -= consumo
if fuel < 350:
color = "red" # combustible vaciandose
elif keypressed(1) == 'Right' and fuel > 0:
vx += impulso_x
fuel -= consumo
if fuel < 350:
color = "red" # combustible vaciandose
y += vy
x += vx
px += vpx
if px <= 0 or px >= anchura_paisaje - anchura_plataforma:
vpx = -vpx
move(nave, vx, vy)
move(plataforma, vpx, 0)
viejo_lleno = lleno
lleno = create_filled_rectangle(1,altura_paisaje, 9, altura_paisaje-fuel/10, color)
erase(viejo_lleno)
vieja_aguja = aguja
aguja = create_line(anchura_paisaje-50, altura_paisaje-50, \
anchura_paisaje-50 + 50 * sin(1000*vy*pi/180), \
altura_paisaje-50 + 50 * cos(1000*vy*pi/180), 'black')
erase(vieja_aguja)
msg_x = anchura_paisaje/2
msg_y1 = altura_paisaje/2
msg_y2 = altura_paisaje/3
if y >= altura_paisaje:
create_text(msg_x, msg_y1, 'Perdiste', 24, 'CENTER')
create_text(msg_x, msg_y2, 'Rumbo a las estrellas?', 12, 'CENTER')
elif y <= 0 and vy < -0.1:
create_text(msg_x, msg_y1, 'Perdiste', 24, 'CENTER')
create_text(msg_x, msg_y2, 'Te has estrellado.', 12, 'CENTER')
elif y <= 0 and \
abs((px+anchura_plataforma/2)-(x+tamanyo_nave/2)) >= anchura_plataforma/2:
create_text(msg_x, msg_y1, 'Perdiste', 24, 'CENTER')
create_text(msg_x, msg_y2, ' !Que mala puntería!', 12, 'CENTER')
elif x <= 0 or x >= anchura_paisaje - tamanyo_nave:
create_text(msg_x, msg_y1, 'Perdiste', 24, 'CENTER')
create_text(msg_x, msg_y2, 'Chocaste con la pared.', 12, 'CENTER')
else:
create_text(msg_x, msg_y1, 'Ganaste', 24, 'CENTER')
create_text(msg_x, msg_y2, ' !Enhorabuena, piloto!', 12, 'CENTER')
time.sleep(4)
erase(nave)
erase(plataforma)
erase(rect_inicio)
erase(lleno)
#-----------------------------------------------------------------#
elif keypressed(2) == str("m"):
print "Nivel medio"
elif keypressed(2) == str("h"):
print "Nivel dificil"
#-----------------------------------------------------------------#
elif keypressed(2) == str("x"):
print "Saliendo..."
a = keypressed(2)
else:
error = create_text(200,50,"Error! Press another key",11,"CENTER","red")
time.sleep(2) # Espera 2 segundos y borra el objeto(mensaje)
erase(error)
print"salistes"
Setup(setup.py)
from cx_Freeze import setup, Executable
setup(
name = "" ,
version = "0.1" ,
description = "" ,
executables = [Executable("menu_libro_blanco.py")]
)
Bueno, te digo he utilizado la librería modulepythong para la creación, y ya he compilado otros programas sin librería y los compila bien.
Te facilito URL de pythong
http://www3.uji.es/~dllorens/downloads/pythong/windows/ (http://www3.uji.es/~dllorens/downloads/pythong/windows/)
Te agradezco tu ayuda.