In python 3,
execfile no longer exists. You can open it and
execute it manually:
def xfile(afile, globalz=None, localz=None):
with open(afile, "r") as fh:
exec(fh.read(), globalz, localz)
And to execute:
>>> xfile(r'C:path ofilescript.py')
Credit to: What
is an alternative to execfile in Python 3.0?
That's how you execute files from the interpreter.
Another way, you can execute it from the command prompt. Just open it
$ cd filepath
$ python file.py
About the script you're running, there's also a confusion. Whatever
example you are following, it's a Python 2 example, yet you are using
Python 3. Change the request line to this:
htmlfile = urllib.request.urlopen("http://google.com")
Hope this helps!