Top.Mail.Ru
Ответы

Программирование на Python

Помогите пожалуйста, когда пытаюсь превратить .py в .exe c помощью pyinstaller -w fanoocno2.py, программа выводит ошибку (скинула фотографию) , а когда с помощью pyinstaller fanoocno2.py открывается и сразу закрывается командная строка

вот часть кода программы

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
 import tkinter as tk 
from tkinter import filedialog 
import os 
 
 
class Node: 
    def __init__(self, key, value): 
        self.key = key 
        self.value = value 
        self.possibility = 0.0 
        self.code = "" 
 
 
class Encode: 
    def __init__(self): 
        self.frequencies = [] 
 
    def main(self): 
        self.root = tk.Tk() 
        self.root.title("Шифратор Шеннона-Фано") 
        self.root.geometry("600x400") 
 
        # Создание фрейма для контента 
        content = tk.Frame(self.root) 
        content.pack(pady=10) 
 
        # Заголовок 
        title = tk.Label(content, text="Шифратор Шеннона-Фано", font=("Helvetica", 16)) 
        title.pack() 
 
        # Инструкция 
        instructions = tk.Label(content, text="Убедитесь, что в вашем сообщении пробел заменен на '_'", fg="gray") 
        instructions.pack() 
 
        # Фрейм для кнопок 
        buttons = tk.Frame(content) 
        buttons.pack(pady=(10, 0)) 
 
        # Кнопка выбора файла 
        choose_button = tk.Button(buttons, text="Выбрать файл", command=self.choose_file) 
        choose_button.grid(row=0, column=0, padx=10) 
 
        # Кнопка шифрования 
        self.encode_button = tk.Button(buttons, text="Зашифровать", state=tk.DISABLED, command=self.encode) 
        self.encode_button.grid(row=0, column=1, padx=10) 
 
        # Кнопка очистки 
        clear_button = tk.Button(buttons, text="Очистить", command=self.clear_data) 
        clear_button.grid(row=0, column=2, padx=10) 
 
        # Фрейм для кнопок загрузки 
        downloads = tk.Frame(content) 
        downloads.pack(pady=(5, 0)) 
 
        # Кнопка загрузки зашифрованного 
        download_encoded = tk.Button(downloads, text="Скачать зашифрованное", command=self.download_encoded) 
        download_encoded.grid(row=0, column=0, padx=10) 
 
        # Кнопка загрузки кодов 
        download_codes = tk.Button(downloads, text="Скачать коды", command=self.download_codes) 
        download_codes.grid(row=0, column=1, padx=10) 
 
        # Фрейм для результатов 
        results = tk.Frame(content) 
        results.pack(pady=(10, 0)) 
 
        # Метка и текстовое поле для зашифрованного текста 
        self.encoded_label = tk.Label(results, text="Зашифрованный текст:") 
        self.encoded_text = tk.Text(results, height=10, width=50) 
        self.encoded_label.grid(row=0, column=0, sticky="w") 
        self.encoded_text.grid(row=0, column=1, padx=10) 
 
        # Метка и текстовое поле для кодов 
        self.codes_label = tk.Label(results, text="Коды:") 
        self.codes_text = tk.Text(results, height=10, width=50) 
        self.codes_label.grid(row=1, column=0, sticky="w") 
        self.codes_text.grid(row=1, column=1, padx=10) 
 
        self.root.protocol("WM_DELETE_WINDOW", self.on_close) 
        self.root.mainloop()  
По дате
По рейтингу
Аватар пользователя
Новичок

Ваш случай уже обсуждался
Для полноты не хватает вашего варианта использования pyinstaller.exe
Та, что ниже ещё никому ничего не решила. Это здешний призрак
Упс! Он снова дематериализовался



Видео по теме