After import sys
, I use sys.argv
to get input arguments.
But after I compile my program with PyInstaller, the exe program will not accept my input. Instead, it uses the default value I set for the program.
If I run it with python this_script.py
it waits for my input to specify the wait_time
. However, after I compile it with PyInstaller, if I double click the exe file there is no place for me to input the wait_time
.
How can I compile it and let the exe file accept my input?
import sched, time
import sys
s = sched.scheduler(time.time, time.sleep)
# wait_time is an integer representing how many seconds to wait.
def do_something(sc, wait_time):
# Here will be the code for doing something every after "wait_time " seconds
sc.enter(wait_time, 1, do_something, (sc, wait_time))
try:
wait_time = int(sys.argv[1])
except IndexError:
wait_time = 5
# s.enter(wait_time, 1, do_something, (s,))
s.enter(wait_time, 5, do_something, (s, wait_time))
s.run()
.exe
file? Are you running it from a command prompt or are you clicking on it?