PyInstaller将EXE停止转换为在Python 3.6 64位上运行

时间:2018-05-26 10:02:16

标签: python python-3.x pyinstaller

我遇到一条错误消息,指出.exe已转换.exe已停止工作。所以我编写了一个测试代码来验证我使用的python库是否存在任何问题。

以下是转换为import random import pygame gamedisplay = pygame.display.set_mode((200, 200)) pygame.init() while 1 == 1: print(random.randint(1, 2)) 后可以使用的测试代码。

.exe

以下是转换为import pygame import random import time import os.path pygame.init() gameDisplay = pygame.display.set_mode((400, 400)) clock = pygame.time.Clock() font = pygame.font.SysFont(None, 30) stop = False bokmål = ['slett','av den','trev','svingte','sank','synest','slikke','nytter','slipp','frem','steder','enten','besøke','plukket','satt','deres','jobbe','husk'] nynorsk = ['sleit','av han','treiv','svinga','sokk','synest','sleike','nyttar','slepp','fram','stadar','anten','besøke','plukke','sett','dokkar','jobbe','hugs'] wrong_numbers = 0 random_number = random.randint(0, len(bokmål)) right_numbers = 0 words_typed_wrong = [] menu = False answer = '' answer_done = False button_pressed = '' filplasering = '' change_filplasering = False menu_out = False navn_på_dock = '' change_navn_på_dock = False shift = False def message_to_screen (melding, farge, x, y): screen_text = font.render (melding, True, farge) gameDisplay.blit (screen_text, (x, y)) def text_opperating (text, knapp, pos, change): mouse_pos = pygame.mouse.get_pos() mouse_x, mouse_y = mouse_pos mouse_left, f, g = pygame.mouse.get_pressed() x, y = pos if (mouse_x < x + 200 and mouse_x > x) and (mouse_y > y and mouse_y < y + 22): mouse_text = True if mouse_left == 1: change = True else: mouse_text = False if change == True: if knapp == 'backspace': text = text[:-1] elif knapp == 'return': change = False else: text += knapp pygame.draw.rect(gameDisplay, (255, 255, 255), (x - 2, y - 2, 200, 22), 1) gameDisplay.blit(font.render(text, True, (255,255,255)), (x, y)) return ((text, change)) while not stop: gameDisplay.fill((0, 0, 0)) for event in pygame.event.get(): if event.type == pygame.QUIT: stop = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_BACKSPACE: button_pressed = 'backspace' elif event.key == pygame.K_ESCAPE: menu = True button_pressed = 'escape' elif event.key == pygame.K_LSHIFT or event.key == pygame.K_RSHIFT: shift = True elif event.key == pygame.K_SPACE: button_pressed = ' ' elif event.key == pygame.K_RETURN: button_pressed = 'return' elif event.key == pygame.K_SEMICOLON: button_pressed = 'ø' elif event.key == pygame.K_LEFTBRACKET: button_pressed = 'å' elif event.key == pygame.K_QUOTE: button_pressed = 'æ' else: button_pressed = pygame.key.name(event.key) if event.type == pygame.KEYUP: if event.key == pygame.K_LSHIFT or event.key == pygame.K_RSHIFT: shift = False if shift == True: if button_pressed == '.': button_pressed = ':' button_pressed = button_pressed.upper() elif button_pressed == '=': button_pressed = '\\' if menu == True: if menu_out == True and button_pressed == 'escape': menu = False change_filplasering = False change_navn_på_dock = False menu_out = True pygame.draw.rect(gameDisplay, (100, 100, 200), (150, 150, 200, 50)) gameDisplay.blit(font.render('lagre dokument', True, (255, 255, 255)), (170, 165)) message_to_screen(('Antall ord: ' + str(len(bokmål))),(255, 255, 255), 20, 20) message_to_screen('filplasering: ',(255, 255, 255), 20, 50) message_to_screen('navn:', (255, 255, 255), 20, 80) filplasering, change_filplasering = text_opperating(filplasering, button_pressed, (150, 50), change_filplasering) navn_på_dock, change_navn_på_dock = text_opperating(navn_på_dock, button_pressed, (150, 80), change_navn_på_dock) mouse_x, mouse_y = pygame.mouse.get_pos() mouse_left, gh, fd = pygame.mouse.get_pressed() if mouse_x > 150 and mouse_x < 350 and mouse_y > 150 and mouse_y < 200 and mouse_left == True: complet_file = os.path.join(filplasering, navn_på_dock + ".txt") file = open(complet_file, "w") file.write(str(words_typed_wrong)) file.close() else: if button_pressed == 'return': answer_done = True elif button_pressed == 'backspace': answer = answer [:-1] else: answer += button_pressed menu_out = False if answer_done == True: answer_done = False if answer == nynorsk[random_number]: right_numbers += 1 gameDisplay.fill((0, 0, 0)) pygame.draw.polygon(gameDisplay, (0, 255, 0), ((150, 200), (90, 140), (110, 120), (150, 160), (280, 50), (300, 70))) pygame.display.update() time.sleep(1) random_number = random.randint(0, len(bokmål) - 1) else: wrong_numbers += 1 gameDisplay.fill((255, 0, 0)) text = 'feil svar, riktig svar er: ' + nynorsk[random_number] gameDisplay.blit(font.render(text, True, (255, 255, 255)), (25, 100)) pygame.display.update() time.sleep(2) words_typed_wrong.append(nynorsk[random_number]) answer = '' pygame.draw.rect(gameDisplay, (255, 255, 255), (100, 300, 200, 50), 5) pygame.draw.rect(gameDisplay, (255, 255, 255), (100, 100, 200, 50), 5) gameDisplay.blit (font.render (('feil ord: ' + str(wrong_numbers)), True, (255, 255, 255)), (25, 10)) gameDisplay.blit (font.render (('riktige ord: ' + str(right_numbers)), True, (255, 255, 255)), (150, 10)) gameDisplay.blit (font.render (bokmål[random_number], True, (255, 255, 255)), (110, 110)) gameDisplay.blit (font.render (answer, True, (255, 255, 255)), (110, 310)) if random_number == len(bokmål) - 1: pygame.draw.rect(gameDisplay, (255, 0, 0), (0, 0, 20, 20)) button_pressed = '' pygame.display.update() clock.tick(60) 后无效的代码。

Error. Cannot connect to database: SQLSTATE[HYT00]: [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired

1 个答案:

答案 0 :(得分:0)

我找到了问题的解决方案。我没有发现出了什么问题,但我尝试了cx_freeze而不是它的工作原理。我不知道出了什么问题,但如果你看过这个视频:https://www.youtube.com/watch?v=GSoOwSqTSrs 并使用cx_freeze描述中的代码: http://cx-freeze.readthedocs.io/en/latest/distutils.html 你可能会让它上班。