Python tracebacks
14 Aug 2018Common traceback errors:1
- SyntaxError
- ImportError or ModuleNotFoundError
- AttributeError
- NameError
SyntaxError
>>> print('This is a test)
SyntaxError: EOL while scanning string literal
File "syn.py", line 1
def func
^
SyntaxError: invalid syntax
ImportError or ModuleNotFoundError
>>> import some
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named some
AttributeError
>>> my_string = 'Python'
>>> my_string.up()
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
my_string.up()
AttributeError: 'str' object has no attribute 'up'
NameError
>>> print(var)
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
print(var)
NameError: name 'var' is not defined