Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: invu en 23 Junio 2021, 18:46 pm



Título: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 18:46 pm
Buenas tardes, he estado intentando convertir en un exe un script, pero sigue apareciendo esto en el cmd cuando lo trato de convertir:

D:\Códigos\Repositorio Python\vydia\FisAttack>pyinstaller main.py --onefile --noconsole
SyntaxError: Non-UTF-8 code starting with '\xf3' in file D:\Códigos\Compiladores\Python\Scripts\pyinstaller-script.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Ya tengo instalado Pyinstaller, y lo que utilice para realizar el script es Pycharm.
De ante mano muchas gracias. Les dejo el codigo:



import pygame
import math
import random
import time
pygame.mixer.pre_init(44100, -16, 2, 512)
pygame.init()
pygame.mixer.set_num_channels(64)

# Resolucion pantalla
resX = 1280
resY = 720
screen = pygame.display.set_mode((resX, resY))

# Titulo e icono
pygame.display.set_caption("The Fis Attack")
icon = pygame.image.load("assets/images/naveIcon.png")
pygame.display.set_icon(icon)

# calcular frames
prev_time = time.time()
dt = 0
fps = 60
clock = pygame.time.Clock()

# Score
scoreDebug = 0
score = scoreDebug
scoreMin = score
scoreMax = 0


# Estrellas 2
estrellaImg = []
estrellaX = []
estrellaY = []
estrellaVel = []
estrellaY_change = []
numEstrellas2 = resX - 600
for i in range(numEstrellas2):
    estrellaImg.append(pygame.image.load("assets/images/estrella.png"))
    estrellaX.append(random.randint(0, resX + i))
    estrellaY.append(random.randint(0, resY + i))
    estrellaVel.append(15)
    estrellaY_change.append(estrellaVel)

def drawEstrellas(x, y, i):
    screen.blit(estrellaImg, (x, y))

# Jugador
playerImg = pygame.image.load("assets/images/navePlayer.png")
playerX = (resX // 2) - 20
playerY = resY - 100
playerX_change = 0
playerY_change = 0
playerVel = 600
estadoJug = True


def player(x, y):
    screen.blit(playerImg, (x, y))


# Enemigo 1
maxMuertesEnemigos1 = 20
enemigo1Img = []
enemigo1X = []
enemigo1Y = []
enemigo1Vel = []
enemigo1X_change = []
enemigo1Y_change = []
numEnemigo1 = 9
for i in range(numEnemigo1):
    enemigo1Img.append(pygame.image.load("assets/images/fis/peby.png"))
    enemigo1X.append(random.randint(0, resX - 64))
    enemigo1Y.append(0)
    enemigo1Vel.append(240)
    enemigo1X_change.append(enemigo1Vel)
    enemigo1Y_change.append(enemigo1Vel)


def enemigo1(x, y, i):
    screen.blit(enemigo1Img, (x, y))


# Enemigo 2
iniciarEnemigo2 = 21
maxMuertesEnemigos2 = 50
enemigo2Img = []
enemigo2X = []
enemigo2Y = []
enemigo2Vel = []
enemigo2X_change = []
enemigo2Y_change = []
numEnemigo2 = 9
enemigoDireccion = []
# Laser enemigo 2
laserEnem2Img = []
laserEnem2X = []
laserEnem2Y = []
laserEnem2Vel = []
laserEnem2Y_change = []
laserEnem2_state = []
for i in range(numEnemigo2):
    enemigo2Img.append(pygame.image.load("assets/images/fis/pacian.png"))
    enemigo2X.append(random.randint(0, resX - 64))
    enemigo2Y.append(0)
    enemigo2Vel.append(280)
    enemigo2X_change.append(enemigo2Vel)
    enemigo2Y_change.append(enemigo2Vel)
    enemigoDireccion.append(0)
    # Laser enemigo 2
    laserEnem2Img.append(pygame.image.load("assets/images/fis/laser_pacian.png"))
    laserEnem2X.append(0)
    laserEnem2Y.append(enemigo2Y)
    laserEnem2Vel.append(460)
    laserEnem2Y_change.append(laserEnem2Vel)
    laserEnem2_state.append(0)


def enemigo2(x, y, i):
    screen.blit(enemigo2Img, (x, y))


def dispararLaserEnem2(x, y, i):
    laserEnem2_state = 1
    screen.blit(laserEnem2Img, (x + 17, y))


# Enemigo 3
iniciarEnemigo3 = 51
maxMuertesEnemigos3 = 70
enemigo3Img = []
enemigo3X = []
enemigo3Y = []
enemigo3Vel = []
enemigo3X_change = []
enemigo3Y_change = []
numEnemigo3 = 8
for i in range(numEnemigo3):
    enemigo3Img.append(pygame.image.load("assets/images/fis/metal_garbage.png"))
    enemigo3X.append(random.randint(0, resX - 64 + i * 2))
    enemigo3Y.append(random.randint(0, 50 + i * 2))
    enemigo3Vel.append(370)
    enemigo3X_change.append(enemigo3Vel)
    enemigo3Y_change.append(enemigo3Vel)


def enemigo3(x, y, i):
    screen.blit(enemigo3Img, (x, y))


# Boss
iniciarBoss = 71
bossImg = pygame.image.load("assets/images/fis/boss/lord_mamamela.png")
hitDamage = 5
vidaBossDebug = 120
vidaBoss = vidaBossDebug
bossX = (resX // 2) - 53
bossY = 0
bossVel = 650
bossX_change = bossVel
bossY_change = 50
# Laser 1 boss
bossLaserImg = pygame.image.load("assets/images/fis/boss/laser_lord.png")
bossLaser1X = 0
bossLaser1Y = 0
laser1BossVel = 700
laser1BossY_Change = laser1BossVel
laser1Boss_state = 0
# Laser 2 boss
bossLaser2X = 0
bossLaser2Y = 0
laser2BossVel = 700
laser2BossY_Change = laser2BossVel
laser2Boss_state = 0


def boss(x, y):
    screen.blit(bossImg, (x, y))


def dispararBossLaser1(x, y):
    screen.blit(bossLaserImg, (x, y))


def dispararBossLaser2(x, y):
    screen.blit(bossLaserImg, (x, y))


# Laser jugador
laserJugadorImg = pygame.image.load("assets/images/laser.png")
laserJugadorX = 0
laserJugadorY = playerY
laserJugadorVel = 4 * playerVel
laserJugadorY_change = laserJugadorVel
laserJugador_state = "ready"


def dispararLaserJugador(x, y):
    global laserJugador_state
    laserJugador_state = "fire"
    screen.blit(laserJugadorImg, (x + 16, y))


# Checando colision
def funcColision(x1, y1, x2, y2, lim):
    distancia = math.sqrt((math.pow(x1 - x2, 2)) + (math.pow(y1 - y2, 2)))
    if distancia < lim:
        return True
    return False


# RGB para pantalla de fondo
redRGB = 70
greenRGB = 68
blueRGB = 124

# Teclas
right = pygame.K_RIGHT
left = pygame.K_LEFT
up = pygame.K_UP
down = pygame.K_DOWN
shoot = pygame.K_s
revive = pygame.K_r


# Sonidos y musica
bossHit = pygame.mixer.Sound("assets/sounds/hitBoss.wav")
bossDeath = pygame.mixer.Sound("assets/sounds/explosionBoss.wav")
shootSound = pygame.mixer.Sound("assets/sounds/shoot.wav")
shootEnemSound = pygame.mixer.Sound("assets/sounds/shootEnem.wav")
shootBossSound = pygame.mixer.Sound("assets/sounds/shootBoss.wav")
hitSound = pygame.mixer.Sound("assets/sounds/hit.wav")
hitJugSound = pygame.mixer.Sound("assets/sounds/hitJug.wav")
hitWallEnem = pygame.mixer.Sound("assets/sounds/hitWallEnem.wav")
hitWallBoss = pygame.mixer.Sound("assets/sounds/hitWallBoss.wav")

pygame.mixer.music.load("assets/music/sweet_victory_by-JosephineMira.ogg")
pygame.mixer.music.play()
pygame.mixer.music.pause()
#################################################################
# Game loop
running = True
while running:
    # Limite de framerate
    clock.tick(fps)
    # Calcular delta time
    now = time.time()
    dt = now - prev_time
    prev_time = now
    # Pantalla de fondo
    screen.fill((redRGB, greenRGB, blueRGB))
    # Estrellas
    for i in range(numEstrellas2):
        drawEstrellas(estrellaX + 1, estrellaY + 1, i)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

            # Movimiento
        if event.type == pygame.KEYDOWN:
            if event.key == right:
                playerX_change = playerVel * dt
            if event.key == left:
                playerX_change = (playerVel * -1) * dt
                # if event.key == down:
                #    playerY_change = playerVel
                # if event.key == up:
                #    playerY_change = playerVel * -1
            if estadoJug:
                if vidaBoss >= 1:
                    if event.key == shoot:
                        if laserJugador_state == "ready":
                            laserJugadorX = playerX
                            dispararLaserJugador(laserJugadorX, laserJugadorY)
                            shootSound.play()
            if not estadoJug:
                if event.key == revive:
                    estadoJug = True
                    playerY = resY - 100
                    playerX = (resX // 2) - 20
                    playerY_change = 0

    # Creditos
    if vidaBoss > 0:
        playerX += playerX_change
    if vidaBoss <= 0:
        playerY -= playerY_change
        playerY_change = 6 * dt
        for i in range(numEstrellas2):
            estrellaY += estrellaY_change * dt
            if estrellaY >= resY + 2:
                estrellaY = random.randint(-400, 0)
                estrellaX = random.randint(0, resX)

    # Poner limites de movimiento
    if playerX <= 0:
        playerX = 0
    elif playerX >= resX - 64:
        playerX = resX - 64

    # Resetear pos de enemigos
    if not estadoJug:
        # Enemigo 1
        for i in range(numEnemigo1):
            enemigo1Y = 0
        # Enemigo laser
        for i in range(numEnemigo2):
            laserEnem2_state = 0
        # Enemigo 3
        for i in range(numEnemigo3):
            enemigo3X = random.randint(0, resX - 64 + i * 2)
            enemigo3Y = random.randint(0, 50 + i * 2)
        # Boss
        vidaBoss = vidaBossDebug
        bossX = (resX // 2) - 53
        bossY = 0
        laser1Boss_state = 0
        laser2Boss_state = 0
    # enemigo 1
    if score <= maxMuertesEnemigos1:
        for i in range(numEnemigo1):
            enemigo1Y += enemigo1Y_change * dt
            enemigo1X += enemigo1X_change * dt
            if enemigo1X <= 0:
                hitWallBoss.play()
                enemigo1X_change = enemigo1Vel
            elif enemigo1X >= resX - 64:
                hitWallBoss.play()
                enemigo1X_change = enemigo1Vel * -1
            if enemigo1Y > resY + 10:
                enemigo1Y = 0
            # Colision
            colisionLaser = funcColision(enemigo1X, enemigo1Y, laserJugadorX, laserJugadorY, 40)
            if colisionLaser:
                laserJugadorY = playerY
                laserJugador_state = "ready"
                hitSound.play()
                score += 1
                enemigo1X = random.randint(0, resX - 64)
                enemigo1Y = 0
            # Muerte Jug
            colisionJug = funcColision(enemigo1X, enemigo1Y, playerX, playerY, 64)
            if estadoJug:
                if colisionJug:
                    hitJugSound.play()
                    estadoJug = False
                    playerX_change = 0
                    laserJugadorX = 100000

            enemigo1(enemigo1X, enemigo1Y, i)

    # enemigo 2
    if estadoJug:
        if iniciarEnemigo2 <= score <= maxMuertesEnemigos2:
            for i in range(numEnemigo2):
                enemigo2X += enemigo2X_change * dt
                if enemigo2X <= 0:
                    enemigo2X_change = enemigo2Vel
                    enemigoDireccion = 0
                elif enemigo2X >= resX - 64:
                    enemigo2X_change = enemigo2Vel * -1
                    enemigoDireccion = 1
                # Colision laser hacia enemigo
                colisionLaser = funcColision(enemigo2X, enemigo2Y, laserJugadorX, laserJugadorY, 40)
                if colisionLaser:
                    hitSound.play()
                    laserJugadorY = playerY
                    laserJugador_state = "ready"
                    score += 1
                    enemigo2X = random.randint(0, resX - 64)
                    enemigo2Y = 0

                # Laser
                if laserEnem2_state == 0:
                    laserEnem2_state = 1
                    shootEnemSound.play()
                    if enemigoDireccion == 0:
                        laserEnem2X = enemigo2X + 7
                    if enemigoDireccion == 1:
                        laserEnem2X = enemigo2X - 7
                    laserEnem2Y = enemigo2Y + 20
                if laserEnem2_state == 1:
                    dispararLaserEnem2(laserEnem2X, laserEnem2Y, i)
                    laserEnem2Y += laserEnem2Y_change * dt
                if laserEnem2Y >= resY:
                    laserEnem2_state = 0
                # Muerte Jug con laser
                colisionEnemLaser = funcColision(playerX, playerY, laserEnem2X, laserEnem2Y, 30)
                if estadoJug:
                    if colisionEnemLaser:
                        hitJugSound.play()
                        estadoJug = False
                        playerX_change = 0
                        laserJugadorX = 100000

                enemigo2(enemigo2X, enemigo2Y, i)

    # Enemigo 3
    if estadoJug:
        if iniciarEnemigo3 <= score <= maxMuertesEnemigos3:
            for i in range(numEnemigo3):
                enemigo3Y += enemigo3Y_change * dt
                enemigo3X += enemigo3X_change * dt
                if enemigo3X <= 0:
                    enemigo3X_change = enemigo3Vel
                    hitWallEnem.play()
                elif enemigo3X >= resX - 64:
                    enemigo3X_change = enemigo3Vel * -1
                    hitWallEnem.play()
                if enemigo3Y <= 0:
                    enemigo3Y_change = enemigo3Vel
                    hitWallEnem.play()
                elif enemigo3Y >= resY - 64:
                    enemigo3Y_change = enemigo3Vel * -1
                    hitWallEnem.play()
                # Colision
                colisionLaser = funcColision(enemigo3X, enemigo3Y, laserJugadorX, laserJugadorY, 40)
                if colisionLaser:
                    laserJugadorY = playerY
                    laserJugador_state = "ready"
                    hitSound.play()
                    score += 1
                    enemigo3X = random.randint(0, resX - 64)
                    enemigo3Y = 0
                # Muerte Jug
                colisionJug = funcColision(enemigo3X, enemigo3Y, playerX, playerY, 64)
                if estadoJug:
                    if colisionJug:
                        hitJugSound.play()
                        estadoJug = False
                        playerX_change = 0
                        laserJugadorX = 100000

                enemigo3(enemigo3X, enemigo3Y, i)

    # Boss
    if estadoJug:
        if score >= iniciarBoss and vidaBoss > 0:
            bossX += bossX_change * dt
            if bossX >= resX - 128:
                bossX_change = bossVel * -1
                hitWallBoss.play()
                bossY += bossY_change

            if bossX <= 0:
                bossX_change = bossVel
                hitWallBoss.play()
                bossY += bossY_change

            # Laser jug hacia Boss
            colisionLaser = funcColision(bossX + 29, bossY, laserJugadorX, laserJugadorY, 74)
            if colisionLaser:
                laserJugadorY = playerY
                laserJugador_state = "ready"
                bossHit.play()
                vidaBoss -= hitDamage

                if vidaBoss < 1:
                    bossDeath.play()
            # Muerte Jug
            colisionJug = funcColision(bossX + 29, bossY, playerX, playerY, 128)
            if estadoJug:
                if colisionJug:
                    hitJugSound.play()
                    estadoJug = False
                    playerX_change = 0
                    laserJugadorX = 100000

            # Laser 1
            if laser1Boss_state == 0:
                laser1Boss_state = 1
                # inserte sonido aqui
                shootBossSound.play()
                bossLaser1X = bossX - 4
                bossLaser1Y = bossY + 64
            if laser1Boss_state == 1:
                dispararBossLaser1(bossLaser1X, bossLaser1Y)
                bossLaser1Y += laser1BossVel * dt
            if bossLaser1Y >= resY:
                laser1Boss_state = 0
            # Muerte con laser 1
            colisionBossLaser1 = funcColision(playerX, playerY, bossLaser1X, bossLaser1Y, 36)
            if estadoJug:
                if colisionBossLaser1:
                    hitJugSound.play()
                    estadoJug = False
                    playerX_change = 0
                    laserJugadorX = 100000

            # Laser 2
            if laser2Boss_state == 0:
                laser2Boss_state = 1
                # inserte sonido aqui
                shootBossSound.play()
                bossLaser2X = bossX + 68
                bossLaser2Y = bossY + 64
            if laser2Boss_state == 1:
                dispararBossLaser2(bossLaser2X, bossLaser2Y)
                bossLaser2Y += laser2BossVel * dt
            if bossLaser2Y >= resY:
                laser2Boss_state = 0
            # Muerte con laser 1
            colisionBossLaser2 = funcColision(playerX, playerY, bossLaser2X + 10, bossLaser2Y, 36)
            if estadoJug:
                if colisionBossLaser2:
                    hitJugSound.play()
                    estadoJug = False
                    playerX_change = 0
                    laserJugadorX = 100000

            boss(bossX, bossY)

            # graficar vida boss
            rec1Boss = (173, 86, 54)
            rec2Boss = (115, 83, 112)
            pygame.draw.rect(screen, (rec2Boss), [372, 5, vidaBoss * 5 + 16, 40])
            pygame.draw.rect(screen, (rec1Boss), [380, 17, vidaBoss * 5, 15])

    # Que dure el laser en la pantalla
    if laserJugador_state == "ready":
        laserJugadorX = playerX
    if laserJugadorY <= 0:
        laserJugadorX = playerX
        laserJugadorY = playerY
        laserJugador_state = "ready"
    if laserJugador_state == "fire":
        dispararLaserJugador(laserJugadorX, laserJugadorY)
        laserJugadorY -= laserJugadorY_change * dt

    if estadoJug:
        player(playerX, playerY)
    else:
        score = scoreDebug

    # Score max
    scoreMin = score
    if scoreMin > scoreMax:
        scoreMax = score

    # Rectangulo indica score
    if (0 < score < iniciarBoss) and estadoJug:
        primerRec = (111, 161, 211)
        segRec = (52, 75, 98)
        pygame.draw.rect(screen, primerRec, [10, (resY - 110) - (score * 5), 40, score * 5 + 8])
        pygame.draw.rect(screen, segRec, [20, (resY - 106) - score * 5, 20, score * 5])

    # Pantalla de victoria
    if vidaBoss <= 0:
        pygame.mixer.music.unpause()

    pygame.display.update()


Título: Re: Problema al convertir un script en ejecutable
Publicado por: Danielㅤ en 23 Junio 2021, 19:16 pm
Hola, el error te indica que tú código no inicia con una codificación UTF-8, debés insertar la siguiente línea al comienzo de tu código, es decir en la primera línea:

Código
  1. # -*- coding: utf-8 -*-

Realiza lo que te comenté y luego nos comentas si funcionó.


Saludos


Título: Re: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 19:36 pm
Hola, el error te indica que tú código no inicia con una codificación UTF-8, debés insertar la siguiente línea al comienzo de tu código, es decir en la primera línea:

Código
  1. # -*- coding: utf-8 -*-

Realiza lo que te comenté y luego nos comentas si funcionó.


Saludos


Ohh, okey, ¿de ésta manera?

1. # -*- coding: utf-8 -*-
2. import pygame
3. import math
4. import random



Ya lo hice y me sigue apareciendo esto en el cmd:


D:\Códigos\Repositorio Python\vydia\FisAttack>pyinstaller main.py --onefile --noconsole
SyntaxError: Non-UTF-8 code starting with '\xf3' in file D:\Códigos\Compiladores\Python\Scripts\pyinstaller-script.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details



Título: Re: Problema al convertir un script en ejecutable
Publicado por: EdePC en 23 Junio 2021, 20:31 pm
Ahí dice que el problema es con el archivo D:\Códigos\Compiladores\Python\Scripts\pyinstaller-script.py me acabo de instalar el PyInstaller y no veo que me haya creado algún pyinstaller-script.py, además tampoco veo que le haya importado como este codificado mi archivo, ansi, utf-8, con bom, sin bom, etc nunca dio error.


Título: Re: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 21:03 pm
Ahí dice que el problema es con el archivo D:\Códigos\Compiladores\Python\Scripts\pyinstaller-script.py me acabo de instalar el PyInstaller y no veo que me haya creado algún pyinstaller-script.py, además tampoco veo que le haya importado como este codificado mi archivo, ansi, utf-8, con bom, sin bom, etc nunca dio error.


Listo, muchas gracias!!!

Fui a ese archivo .py y en la primera linea le puse lo del uft8.
Muchisimas gracias a Daniel, tambien.


Título: Re: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 21:20 pm

Listo, muchas gracias!!!

Fui a ese archivo .py y en la primera linea le puse lo del uft8.
Muchisimas gracias a Daniel, tambien.

No, ya nada jajajaj

No aparece el archivo .exe en la carpeta dist, pero sí hace todo lo demás de la carpeta build y eso.
Me imagino que es por este error que ahora aparece:

226 INFO: Building PYZ (ZlibArchive) D:\Códigos\Repositorio Python\vydia\FisAttack\build\main\out00-PYZ.pyz
Traceback (most recent call last):
  File "D:\Códigos\Compiladores\Python\Scripts\pyinstaller-script.py", line 34, in <module>
    sys.exit(load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')())
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\__main__.py", line 94, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
    self.__postinit__()
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
    self.assemble()
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
    self.code_dict = {
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\utils.py", line 624, in strip_paths_in_code
    consts = tuple(
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\utils.py", line 625, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "D:\Códigos\Compiladores\Python\lib\site-packages\PyInstaller\building\utils.py", line 632, in strip_paths_in_code
    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)






Título: Re: Problema al convertir un script en ejecutable
Publicado por: EdePC en 23 Junio 2021, 21:34 pm
Ese PyInstaller está medio raro como ya comenté antes, la última versión es la 4.2: https://www.pyinstaller.org/downloads.html yo lo he instalado vía pip


Título: Re: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 21:42 pm
Ese PyInstaller está medio raro como ya comenté antes, la última versión es la 4.2: https://www.pyinstaller.org/downloads.html yo lo he instalado vía pip


Ohhh, ya vi. No me quiere instalar el pyinstaller más reciente. Me instala el 3.4 o menor, incluso con ese sale error de wheel metada.

Cuando quiere instalar el 4.3 sale este error:

PS D:\Códigos\Repositorio Python\vydia\FisAttack> pip install --upgrade pyinstaller
Requirement already satisfied: pyinstaller in d:\códigos\compiladores\python\lib\site-packages (3.3.1)
Collecting pyinstaller
  Using cached pyinstaller-4.3.tar.gz (3.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\códigos\compiladores\python\python.exe' 'd:\códigos\compiladores\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\invu7\AppData\Local\Temp\tmp7bjmdie3'
         cwd: C:\Users\invu7\AppData\Local\Temp\pip-install-zx3_digg\pyinstaller_88a885d95e934b5fa8469242248b653f
    Complete output (40 lines):
    Error in sitecustomize; set PYTHONVERBOSE for traceback:
    SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xf3 in position 0: unexpected end of data (sitecustomize.py, line 7)
    running dist_info
    creating C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info
    writing C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\PKG-INFO
    writing dependency_links to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\dependency_links.txt
    writing entry points to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\entry_points.txt
    writing requirements to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\requires.txt
    writing top-level names to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\top_level.txt
    writing manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\SOURCES.txt'
    warning: the 'license_file' option is deprecated, use 'license_files' instead
    adding license file 'COPYING.txt' (matched pattern 'COPYING.txt')
    reading manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'pyinstaller-gui.py'
    no previously-included directories found matching 'bootloader\build'
    no previously-included directories found matching 'bootloader\.waf-*'
    no previously-included directories found matching 'bootloader\.waf3-*'
    no previously-included directories found matching 'bootloader\waf-*'
    no previously-included directories found matching 'bootloader\waf3-*'
    no previously-included directories found matching 'bootloader\_sdks'
    no previously-included directories found matching 'bootloader\.vagrant'
    warning: no previously-included files found matching 'bootloader\.lock-waf*'
    no previously-included directories found matching 'doc\source'
    no previously-included directories found matching 'doc\_build'
    warning: no previously-included files matching '*.tmp' found under directory 'doc'
    warning: no files found matching 'news\_template.rst'
    no previously-included directories found matching 'news'
    no previously-included directories found matching 'old'
    no previously-included directories found matching 'scripts'
    no previously-included directories found matching 'tests\scripts'
    no previously-included directories found matching '.github'
    warning: no previously-included files found matching '.*'
    warning: no previously-included files found matching '*.yml'
    warning: no previously-included files found matching '*~'
    warning: no previously-included files found matching '.directory'
    warning: no previously-included files matching '*.py[co]' found anywhere in distribution
    writing manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.egg-info\SOURCES.txt'
    creating 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-2vfgtnvy\pyinstaller.dist-info'
    error: invalid command 'bdist_wheel'
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/b6/27/a006fcadba0db30819c968eb8decb4937cda398ca7a44d8874172cdc228a/pyinstaller-4.3.tar.gz#sha256=5ecf8bbc230d7298a796e52bb745b95eee12878d141f1645612c99246ecd23f2 (from https://pypi.org/simple/pyinstaller/) (requires-python:>=3.6). Command errored out with exit status 1: 'd:\códigos\compiladores\python\python.exe' 'd:\códigos\compiladores\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\invu7\AppData\Local\Temp\tmp7bjmdie3' Check the logs for full command output.
  Using cached pyinstaller-4.2.tar.gz (3.6 MB)


Título: Re: Problema al convertir un script en ejecutable
Publicado por: Danielㅤ en 23 Junio 2021, 21:55 pm
Puedes actualizar la versión de tu pyinstaller con el siguiente comando:

Código:
pip install --upgrade pyinstaller

También puedes usar py2exe que es muy bueno:

https://www.py2exe.org/


Saludos


Título: Re: Problema al convertir un script en ejecutable
Publicado por: invu en 23 Junio 2021, 21:59 pm
Puedes actualizar la versión de tu pyinstaller con el siguiente comando:

Código:
pip install --upgrade pyinstaller


Saludos

Eso mismo hice xd
Y pues sale lo que mandé;

PS D:\Códigos\Repositorio Python\vydia\FisAttack> pip install --upgrade pyinstaller
Requirement already satisfied: pyinstaller in d:\códigos\compiladores\python\lib\site-packages (3.3.1)
Collecting pyinstaller
  Using cached pyinstaller-4.3.tar.gz (3.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\códigos\compiladores\python\python.exe' 'd:\códigos\compiladores\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\invu7\AppData\Local\Temp\tmp49woi11y'
         cwd: C:\Users\invu7\AppData\Local\Temp\pip-install-f0qqna0r\pyinstaller_e9b1de260152476a9fac00e00af32a65
    Complete output (40 lines):
    Error in sitecustomize; set PYTHONVERBOSE for traceback:
    SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xf3 in position 0: unexpected end of data (sitecustomize.py, line 7)
    running dist_info
    creating C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info
    writing C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\PKG-INFO
    writing dependency_links to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\dependency_links.txt
    writing entry points to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\entry_points.txt
    writing requirements to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\requires.txt
    writing top-level names to C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\top_level.txt
    writing manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\SOURCES.txt'
    warning: the 'license_file' option is deprecated, use 'license_files' instead
    adding license file 'COPYING.txt' (matched pattern 'COPYING.txt')
    reading manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'pyinstaller-gui.py'
    no previously-included directories found matching 'bootloader\build'
    no previously-included directories found matching 'bootloader\.waf-*'
    no previously-included directories found matching 'bootloader\.waf3-*'
    no previously-included directories found matching 'bootloader\waf-*'
    no previously-included directories found matching 'bootloader\waf3-*'
    no previously-included directories found matching 'bootloader\_sdks'
    no previously-included directories found matching 'bootloader\.vagrant'
    warning: no previously-included files found matching 'bootloader\.lock-waf*'
    no previously-included directories found matching 'doc\source'
    no previously-included directories found matching 'doc\_build'
    warning: no previously-included files matching '*.tmp' found under directory 'doc'
    warning: no files found matching 'news\_template.rst'
    no previously-included directories found matching 'news'
    no previously-included directories found matching 'old'
    no previously-included directories found matching 'scripts'
    no previously-included directories found matching 'tests\scripts'
    no previously-included directories found matching '.github'
    warning: no previously-included files found matching '.*'
    warning: no previously-included files found matching '*.yml'
    warning: no previously-included files found matching '*~'
    warning: no previously-included files found matching '.directory'
    warning: no previously-included files matching '*.py[co]' found anywhere in distribution
    writing manifest file 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.egg-info\SOURCES.txt'
    creating 'C:\Users\invu7\AppData\Local\Temp\pip-modern-metadata-pdzf41zh\pyinstaller.dist-info'
    error: invalid command 'bdist_wheel'
    ----------------------------------------


Título: Re: Problema al convertir un script en ejecutable
Publicado por: DtxdF en 24 Junio 2021, 00:25 am
Hola @invu

Además de colocar lo que recomienda el mismo Python, tu editor de código debe poder escribir en UTF-8.

En vim:

Código:
set encoding=utf-8
set fileencoding=utf-8

Fuente: https://vim.fandom.com/wiki/Working_with_Unicode

~ DtxdF


Título: Re: Problema al convertir un script en ejecutable
Publicado por: painpills en 26 Junio 2021, 04:21 am
Si se trata de algún problema relacionado con el pyinstaller lo más sencillo sería buscar una alternativa como por ejemplo "cx_Freeze", Esa opción te permite generar ejecutables aunque utilices librerías de terceros cosa que no puedes hacer con pyinstaller, según yo.

Saludos!  ;-)