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
  problem program runs in a loop jasserin 0 195 May-18-2024, 03:07 PM
Last Post: jasserin
  Are there errors in the code for my coin toss systems? Matlibplot is too perfect . Coolkat 0 459 Nov-13-2023, 11:54 AM
Last Post: Coolkat
  Anaconda 2.4.2: The JupyterLab 3.5.3 fails to run the python code of the Geographical jamalnuman 0 399 Aug-23-2023, 07:48 AM
Last Post: jamalnuman
  Converted EXE file size is too large Rajasekaran 0 1,624 Mar-30-2023, 11:50 AM
Last Post: Rajasekaran
  Another program runs bho68 7 1,317 Nov-08-2022, 08:16 PM
Last Post: bho68
  Python converted EXE not working Rajasekaran 1 1,681 Aug-22-2022, 05:56 PM
Last Post: hismail_sa
  Issue when using open() in converted exe skakalpes 2 1,664 Feb-02-2022, 02:42 PM
Last Post: snippsat
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 3,094 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  Why doesn't this print statement work? stylingpat 10 6,055 Mar-23-2021, 07:54 PM
Last Post: buran
  Embedded python fails to compile on Raspberry Pi tryfon 2 3,605 Dec-22-2020, 02:06 PM
Last Post: tryfon

Forum Jump:

User Panel Messages

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