.exe создается с помощью Pyinstaller: pyinstaller --onefile --windowed --icon=axe.ico main.py
Не удалось удалить временный каталог: C:/users/lucky/AppData/Local/Temp/_MEI135042
Вот мой код:
Код: Выделить всё
import os
import sys
import tkinter
import turtle
import json
import tempfile
import shutil
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "True"
import pygame
STANDARD_KEY_BINDING = ["a", "d", "q"]
def cleanup():
try:
turtle.bye()
except turtle.Terminator:
pass
pygame.quit()
temp_dir = tempfile.gettempdir()
try:
for temp_item in os.listdir(temp_dir):
temp_path = os.path.join(temp_dir, temp_item)
if os.path.isdir(temp_path) and "your-app-name" in temp_item:
shutil.rmtree(temp_path)
print(f"Removed temporary directory: {temp_path}")
except Exception as e:
print(f"Error removing temporary directory: {e}")
def restart_program():
cleanup()
python = sys.executable
os.execl(python, python, *sys.argv)
def game(map_choice):
# [non-related code]
background.screen.onkey(fun=player.move_left_swing, key=binds[0])
background.screen.onkey(fun=player.move_right_swing, key=binds[1])
background.screen.onkey(fun=restart_program, key=binds[2])
# [non-related code]
Что я пробовал:
Проверил, что временные каталоги доступны, и убедился, что pygame.quit() и черепаха .bye() вызываются в функции cleanup().
Будем благодарны за любую помощь по исправлению этой ошибки!
Подробнее здесь: https://stackoverflow.com/questions/790 ... -directory
Мобильная версия