def restart(): import sys print("argv was",sys.argv) print("sys.executable was", sys.executable) print("restart now") import os os.execv(sys.executable, ['python'] + sys.argv)