단도직입 파이썬(Python) – 파이썬 스크립트를 실행파일로 변환하기 (로또번호 생성 후 과거 자료와 비교하기)

제가 작성한 코드들을 VS Code나 PyCharm이 아닌 실행파일로 변환하여 실행시켜 보려 합니다. 에디터에서만 실행시켜보다 단독 실행파일을 만들어 실행시켜 보는 것도 좋을 것 같아 다소 허술하게 코딩 된 스크립트지만 py2exe 해 봅니다.
하단에 실행파일, 원본 파일 올려놓습니다.
우선 실행파일로 바꿀 python script를 준비합니다. 저는 최근 작성된 Lotto 번호 추출 후 과거 당첨번호와 비교하는 코딩을 작성했는데 그기에 random 번호로 확인할 건지, 직접 번호를 입력할 건지 택할 수 있게 수정하였습니다.
def Choice_Lotto_Num():
choice_Num = []
count = 0
print('1 ~ 45 중에서 중복되지 않게 숫자 6개를 골라 입력하세요!!!')
while count<6:
print(f'{count+1} 번째 입력',end='')
choice = int(input('숫자입력 : '))
if 1 > choice > 45 : print('숫자 범위를 확인하세요!!!')
elif choice_Num.count(choice) == 0 :
choice_Num.append(choice)
count +=1
return choice_Num
번호 6개를 입력받을 Choice_Lotto_Num() 함수를 새로 작성하였고, 아래와 같은 반복문을 추가하였습니다.
while True:
choice=input ('1. 랜덤 숫자 2. 숫자 지정\n')
if choice == '1' :
mylt_num=Random_Lotto_Num()
break
elif choice == '2' :
mylt_num = Choice_Lotto_Num()
break
그리고 Lotto_test.py로 저장합니다.
파이썬 실행파일을 만들기 위해 pyinstaller 모듈을 pip로 간단하게 설치합니다.

pip 업그레이드하라고 노랗게 메시지를 띄웁니다. 우린 또 시키는 대로 말 잘 듣습니다. 말 잘 듣는 남편이라!
바로 pip 업그레이드합니다.

pip 업그레이드까지 성공적으로 마쳤습니다.
C:\Python_code>pyinstaller --onefile Lotto_test.py
컨버전 실행합니다! 화면에 실행파일로 바꾸는 작업을 열심히 보여주더군요.

별문제 없이 실행파일로 변경되었음을 알려줍니다.

lotto_test.exe뿐만 아니라 여러 개의 파일들이 생성되었음을 확인하고 lotto_test.exe의 디렉터리 위치도 확인합니다. (dir lotto_test.*/a/s는 파일명이 lotto_test로 시작하는 모든 리스트를 하위 디렉터리까지 포함하여 화면에 뿌려줍니다.) c:\Python_code\dist로 이동하여 lotto_test_.exe를 실행합니다.
c:\Python_code>cd dist
c:\Python_code\dist>lotto_test

별다른 오류 없이 실행된 결과를 확인할 수 있습니다.
Lotto_test.py, txt를 올려놓습니다.