Python Forum
Runs perfect in Python but fails to print last statement when converted to .exe. Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Runs perfect in Python but fails to print last statement when converted to .exe. Help
#1
This code runs perfect in Python but fails to print last statement(printing calculation) when converted to .exe using pyinstaller. Please Help!

# Defining a function to print error when input is wrong.
def exp():
print('Error! Enter Valid Number')
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
p=float(input('ENTER SUM'))
break
except:
exp()
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
r=float(input('ENTER RATE'))
break
except:
exp()
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
fz=float(input('ENTER TIME IN MONTH'))
break
except:
exp()
t=(fz/12)
# Print the calculation.
print('Interest=Rs',p*t*r/100,'\nAmount to pay=Rs',p+p*t*r/100)
Reply
#2
How do you run the exe? If you just click on it, it will close the window immediately after printing the last line and you just don't see it.
Open cmd, run the exe via command line.
or add a line to wait for user input before finishing the execution.


on a side note - you left that repeating code...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you so much!
Reply
#4
You can add input('Enter') at the end to hold the window open.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Are there errors in the code for my coin toss systems? Matlibplot is too perfect . Coolkat 0 370 Nov-13-2023, 11:54 AM
Last Post: Coolkat
  How to do 100 runs simulation based on the current codes? dududada 6 974 Sep-03-2023, 01:43 PM
Last Post: deanhystad
  Anaconda 2.4.2: The JupyterLab 3.5.3 fails to run the python code of the Geographical jamalnuman 0 331 Aug-23-2023, 07:48 AM
Last Post: jamalnuman
  Converted EXE file size is too large Rajasekaran 0 1,510 Mar-30-2023, 11:50 AM
Last Post: Rajasekaran
  Another program runs bho68 7 1,182 Nov-08-2022, 08:16 PM
Last Post: bho68
  Python converted EXE not working Rajasekaran 1 1,579 Aug-22-2022, 05:56 PM
Last Post: hismail_sa
  Issue when using open() in converted exe skakalpes 2 1,565 Feb-02-2022, 02:42 PM
Last Post: snippsat
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 2,911 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  Importing a function from another file runs the old lines also dedesssse 6 2,544 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  Why doesn't this print statement work? stylingpat 10 5,724 Mar-23-2021, 07:54 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020