run program in Python shell March 6, 2023 by Tarik Use execfile for Python 2: >>> execfile('C:\\test.py') Use exec for Python 3 >>> exec(open("C:\\test.py").read())