To start, am incredibly new to python so please bear with me.
I want to write a very simple script to demonstrate some operations with the list data type. This is an abridged version of my script (It's named listTest.py)
#!/usr/bin/python
import sys
print(sys.version_info)
print “successful start”
print “ “
listAl = [ a, b, c, d, e, f, g]
listNu = [ 1, 2, 3, 4, 5, 6]
print listAl
print listNu
To run it, I open op my terminal with spotlight search on my mac (macOS 10.12.6) and type in
python
which runs python 2.7.10. I also have python 3.5.1 which I know I can run with
python3
With my python 2.7.10 prompt open I type the following (left the python starting entry for complete transparency)
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> listTest.py
and get the following message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'listTest' is not defined
>>>
Now, I have no clue what to do at this point. At first I was concerned that I hadn't installed python properly (which I hadn't since python 2.7.10 came with this OS by default) so I checked that I had all my essential components to python. I was missing pip, so I installed pip (here is the pip and python directories)
/usr/local/bin/pip
/usr/bin/python
Then I was concerned I had my listTest.py text file (UTF-8 encoding) in the wrong directory, so I checked it's location on my computer, by typing
ls Desktop
yep, it's there,(which I think is alright?) along with some other text files that crashed and burned in the same way. I also tried installing a virtual environment (pyvenv) to run the script in hoping it would mitigate the issue but I got the same exact error.
What can I try now? Thank you in advance for being patient.
$ python /full/path/listTest.py), or change your CWD to the dir where your file is before you execute$ python listTest.py.