Pyinstaller로 exe파일로 바꾸려고 하니 에러 메시지가 뜨면서 안되네요

조회수 3511회

여러 개의 Sheet를 가진 엑셀 파일을 불러와서 Sheet 이름이 있는 버튼을 누를 때마다 각 Sheet의 자료 중 하나를 랜덤으로 Text 창에 보이게 하고 클립보드로 복사, State 로 현재 불러온 Sheet를 표시. Ctrl+A를 누를 때마다 클립보드 내용을 붙이게 하고 다시 랜덤으로 다른 자료를 선택, 클립보드로 복사 하는 프로그램을 파이썬으로 만들었습니다. py 파일로는 잘 돌아갔는데, pyinstaller로 exe 파일을 만들려고 하니 RecursionError: maximum recursion depth exceeded 가 발생했습니다. auto-py-to-exe로 만들어보니 파일은 만들어지는데, failed to execute script 에러가 뜨면서 실행이 안되네요. 재귀함수가 있는 것 같지는 않은데 도대체 왜 이러는지 모르겠습니다.

from tkinter import *
import openpyxl
import random
import pyperclip
import keyboard
from time import sleep

wb = openpyxl.load_workbook("sample.xlsx")
sh1 = wb.active
sh1 = wb["A"]
sh2 = wb.active
sh2 = wb["B"]
sh3 = wb.active
sh3 = wb["B"]
sh4 = wb.active
sh4 = wb["D"]
sh5 = wb.active
sh5 = wb["E"]

root = Tk()
root.title("엑셀 랜덤 입력기")
root.geometry("400x350")
root.resizable(False, False)


def p1():
    text.delete(1.0, END)
    state.delete(1.0, END)
    ran1 = sh1.cell(row = random.randrange(1, len(sh1["A"]) + 1), column = 1).value
    text.insert(1.0, ran1)
    pyperclip.copy(ran1)
    state.insert(1.0, "A")

def p2():
    text.delete(1.0, END)
    state.delete(1.0, END)
    ran1 = sh2.cell(row = random.randrange(1, len(sh2["A"]) + 1), column = 1).value
    text.insert(1.0, ran1)
    pyperclip.copy(ran1)
    state.insert(1.0, "B")

def p3():
    text.delete(1.0, END)
    state.delete(1.0, END)
    ran1 = sh3.cell(row = random.randrange(1, len(sh3["A"]) + 1), column = 1).value
    text.insert(1.0, ran1)
    pyperclip.copy(ran1)
    state.insert(1.0, "C")

def p4():
    text.delete(1.0, END)
    state.delete(1.0, END)
    ran1 = sh4.cell(row = random.randrange(1, len(sh4["A"]) + 1), column = 1).value
    text.insert(1.0, ran1)
    pyperclip.copy(ran1)
    state.insert(1.0, "D")

def p5():
    text.delete(1.0, END)
    state.delete(1.0, END)
    ran1 = sh5.cell(row = random.randrange(1, len(sh5["A"]) + 1), column = 1).value
    text.insert(1.0, ran1)
    pyperclip.copy(ran1)
    state.insert(1.0, "E")

def p6():
    text.delete(1.0, END)
    state.delete(1.0, END)
    pyperclip.copy("")
    state.insert(1.0, "")

def kt(Event):
    s = state.get(1.0, END)
    if s.strip() in "A":
        keyboard.send("ctrl+v")
        sleep(0.1)
        text.delete(1.0, END)
        ran1 = sh1.cell(row = random.randrange(1, len(sh1["A"]) + 1), column = 1).value
        text.insert(1.0, ran1)
        pyperclip.copy(ran1)
    elif s.strip() in "B":
        keyboard.send("ctrl+v")
        sleep(0.1)
        text.delete(1.0, END)
        ran1 = sh2.cell(row = random.randrange(1, len(sh2["A"]) + 1), column = 1).value
        text.insert(1.0, ran1)
        pyperclip.copy(ran1)
    elif s.strip() in "C":
        keyboard.send("ctrl+v")
        sleep(0.1)
        text.delete(1.0, END)
        ran1 = sh3.cell(row = random.randrange(1, len(sh3["A"]) + 1), column = 1).value
        text.insert(1.0, ran1)
        pyperclip.copy(ran1)
    elif s.strip() in "D":
        keyboard.send("ctrl+v")
        sleep(0.1)
        text.delete(1.0, END)
        ran1 = sh4.cell(row = random.randrange(1, len(sh4["A"]) + 1), column = 1).value
        text.insert(1.0, ran1)
        pyperclip.copy(ran1)
    elif s.strip() in "E":
        keyboard.send("ctrl+v")
        sleep(0.1)
        text.delete(1.0, END)
        ran1 = sh5.cell(row = random.randrange(1, len(sh5["A"]) + 1), column = 1).value
        text.insert(1.0, ran1)
        pyperclip.copy(ran1)

b1 = Button(root, text="A", command=p1)
b2 = Button(root, text="B", command=p2)
b3 = Button(root, text="C", command=p3)
b4 = Button(root, text="D", command=p4)
b5 = Button(root, text="E", command=p5)
b6 = Button(root, text="Clear", command=p6)
text = Text(root)
state = Text(root)

b1.place(x=10, y=10, width=70, height=30)
b2.place(x=10, y=50, width=70, height=30)
b3.place(x=10, y=90, width=70, height=30)
b4.place(x=10, y=130, width=70, height=30)
b5.place(x=10, y=170, width=70, height=30)
b6.place(x=10, y=210, width=70, height=30)
text.place(x=120, y=10, width=260, height=320)
state.place(x=10, y=300, width=70, height=30)

keyboard.add_hotkey("ctrl+a", kt, args=[""])

wb.close()
root.mainloop()

2 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)