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 답변
-
대충 찾아보니 PyInstaller로 실행파일 만들다가 이 에러를 만난다는 사람들이 2년쯤 전부터 있었습니다. 운이 안 좋으시군요.
https://github.com/pyinstaller/pyinstaller/issues/2919
파이썬 버전을 바꾸라든가 하는 조언들이 있는데 하나씩 시도해 보셔요.
-
openpyxl 때문에 나는 오류입니다.
pyinstaller를 최신 개발자 버전으로 다운 받으신 후에 해보세요.
똑같이 오류가 나올텐데 *.spec 파일이 나오면 메모장으로 열어서 상단에
import sys
sys.setrecursionlimit(5000)
을 넣어주신 후 spec파일을 pyinstaller해보세요.
잘됩니다.
댓글 입력