I create an exe file in PyCharm. But the exe file always disappeared very soon after I clicked it. The program is an infinite cycle. The exe file shouldn't disappear and should appear on my screen all the time. The program is shown below. I think the main reason is that I imported the extension library 'openpyxl' in the program. I intentionally used an infinite loop in the code to keep the exe file running all the time. How can I make the exe file run normally? You can paste the code into PyCharm and create an exe file, then you can test if the exe file can run normally. Thank you.
my code:
import openpyxl
import os
excel_path = os.getcwd() + r"//claim.xlsx"
data = openpyxl.load_workbook(excel_path)
print('success')
testdata2 = 1
while True:
print(testdata2)
testdata1=testdata2+1
command used to create the .exe
:
PS E:\Code\Python\Practice\TestInstallPackage> pyinstaller --onefile main.py