NameError ex1. tripping at the first step!

Hi Peoples,
Your help is much appreciated, this is kind of embarrassing.
I have looked for similar error message posts - but this occurs sooner. I apologise if this is annoying duplication.

I have downloaded Python 3.8.2. and have Atom.

When I am in Powershell, I can see that ex1.py (Exercise 1) and ex2.py are in a directory labelled lpthw. I can initiate python from the powershell, but cannot run the files (when entering either ex1.py or ex1) I get a ‘NameError’, and it says the name ‘ex1’ is not defined.

I can run the first file (ex1.py) from within Atom to the Python terminal, but get the same ‘NameError’ message when I attempt to run the second file.

This is the message that I get in PowerShell.

ex1.py
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘ex1’ is not defined.

Any help would be most appreciated.
thanks heaps in advance,
Michael

In Powershell, are you firing up Python and then typing ex1.py? If so, that’s the error, you need to pass the script as an argument to the interpreter: python ex1.py (make sure you’re in the directory where the scripts are located).

If you’re doing that right already, feel free to post your script and we’ll take a look.

Yes, are you able to post a screenshot so we can see?

Got it - thank you so much.

1 Like