Warning
This project is being split into 3 separate projects:
friendly_traceback
,friendly
, andfriendly_idle
.
The documentation does not reflect this change.
If you are a end-user, just install friendly
until further notice.
Comparison between Python versions: SyntaxErrors¶
In this file, we highlight differences between the information
given by different versions of Python when it comes to SyntaxError
.
The content of this file is likely of no use to anyone except for
people who write code to include new SyntaxError
cases.
The differences between Python versions can be:
The error message itself.
The location of the error as indicated by Python with
^
. We’ve decided to leave these out for now.
As a consequence, the information as to what we guess is the cause can be slightly different. So, we also show when we assign a different cause.
Note that the content below is extracted automaticaly by a simple program we wrote for this purpose. If the information is the same for Python 3.6 and 3.7, but changes for Python 3.8, we only show the differences between 3.7 and 3.8.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: SyntaxError: invalid syntax
Different explanation - by Friendly-traceback
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: You use the augmented assignment operator `:=` where the normal assignment operator `=` was required.
Different messages - from Python
3.8: SyntaxError: invalid syntax 3.9: SyntaxError: trailing comma not allowed without surrounding parentheses
Different explanation - by Friendly-traceback
3.8: The Python keyword `and` can only be used for boolean expressions. Perhaps you meant to write `from math import sin, tan, cos` 3.9: Python gave us the following informative message about the possible cause of the error: trailing comma not allowed without surrounding parentheses However, I do not recognize this information and I have to guess what caused the problem, but I might be wrong. The Python keyword `and` can only be used for boolean expressions. Perhaps you meant to write `from math import sin, tan, cos`
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: multiple exception types must be parenthesized
Different explanation - by Friendly-traceback
3.9: I am guessing that you wanted to use an `except` statement with multiple exception types. If that is the case, you must surround them with parentheses. 3.10: I am guessing that you wanted to use an `except` statement with multiple exception types. If that is the case, you must surround them with parentheses.
Different messages - from Python
3.8: SyntaxError: unexpected EOF while parsing 3.9: IndentationError: expected an indented block
3.10: IndentationError: expected an indented block after 'for' statement on line 3
Different explanation - by Friendly-traceback
3.8: Python tells us that it reached the end of the file and expected more content. 3.9: The line identified above was expected to begin a new indented block.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different explanation - by Friendly-traceback
3.9: It looks as though you forgot to use to use parenthesis with `range`. Perhaps you meant: for i in range( 3): 3.10: Python told us that it expected a colon at the position indicated. However, adding a colon or replacing something else by a colon would not fix the problem. It looks as though you forgot to use to use parenthesis with `range`. Perhaps you meant: for i in range( 3):
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different explanation - by Friendly-traceback
3.9: You likely meant to use Python's `elif` keyword but wrote `else if` instead. 3.10: Python told us that it expected a colon at the position indicated. However, adding a colon or replacing something else by a colon would not fix the problem. You likely meant to use Python's `elif` keyword but wrote `else if` instead.
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: cannot use assignment expressions with True
Different explanation - by Friendly-traceback
3.6: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.6. 3.7: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.7.
3.8: `True` is a constant in Python; you cannot assign it a different value.
Different messages - from Python
3.7: SyntaxError: can't assign to function call 3.8: SyntaxError: cannot assign to function call
3.10: SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?
Different explanation - by Friendly-traceback
3.6: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.6.8. 3.7: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.7.8.
3.8: `/` indicates that the previous arguments in a function definition are positional arguments. You have unspecified keyword arguments that appear before the symbol `/`.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid decimal literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?
Different explanation - by Friendly-traceback
3.9: You likely used an assignment operator `=` instead of an equality operator `==`. 3.10: You wrote an expression that includes some mathematical operations on the left-hand side of the equal sign which should be only used to assign a value to a variable.
Different messages - from Python
3.7: SyntaxError: can't assign to Ellipsis 3.8: SyntaxError: cannot assign to Ellipsis
3.10: SyntaxError: cannot assign to ellipsis here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: '[' was never closed
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: EOF while scanning triple-quoted string literal 3.10: SyntaxError: unterminated triple-quoted string literal (detected at line 4)
Different messages - from Python
3.7: SyntaxError: can't delete literal 3.8: SyntaxError: cannot delete literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: unterminated string literal (detected at line 3)
Different explanation - by Friendly-traceback
3.9: There appears to be a Python identifier (variable name) immediately following a string. I suspect that you were trying to use a quote inside a string that was enclosed in quotes of the same kind. 3.10: You started writing a string with a single or double quote but never ended the string with another quote on that line.
Different messages - from Python
3.6: SyntaxError: Generator expression must be parenthesized if not sole argument 3.7: SyntaxError: Generator expression must be parenthesized
Different messages - from Python
3.9: SyntaxError: EOL while scanning string literal 3.10: SyntaxError: unterminated string literal (detected at line 3)
Different messages - from Python
3.8: SyntaxError: invalid character in identifier 3.9: SyntaxError: invalid character '🤖' (U+1F916)
Different explanation - by Friendly-traceback
3.6: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.6.8. 3.7: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.7.8.
3.8: `/` indicates that the previous arguments in a function definition are positional arguments. However, `*` indicates that the arguments that follow must be keyword arguments. When they are used together, `/` must appear before `*`.
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to literal
3.10: SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: closing parenthesis ']' does not match opening parenthesis '('
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid decimal literal
Different messages - from Python
3.7: SyntaxError: can't assign to operator 3.8: SyntaxError: cannot assign to operator
3.10: SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid hexadecimal literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to f-string expression
3.10: SyntaxError: cannot assign to f-string expression here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.7: SyntaxError: assignment to keyword 3.8: SyntaxError: cannot assign to __debug__
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: unmatched ')'
Different explanation - by Friendly-traceback
3.7: The closing parenthesis `)` on line 6 does not match anything. 6: 3, 4,)) ^ 3.8: The closing parenthesis `)` on line 6 does not match anything.
Different messages - from Python
3.8: SyntaxError: invalid syntax 3.9: SyntaxError: f-string: invalid syntax
3.10: SyntaxError: f-string: cannot use double starred expression here
Different messages - from Python
3.7: SyntaxError: can't assign to conditional expression 3.8: SyntaxError: cannot assign to conditional expression
Different messages - from Python
3.9: SyntaxError: EOL while scanning string literal 3.10: SyntaxError: unterminated string literal (detected at line 1)
Different messages - from Python
3.8: SyntaxError: invalid character in identifier 3.9: SyntaxError: invalid character '«' (U+00AB)
Different messages - from Python
3.7: SyntaxError: can't assign to keyword 3.8: SyntaxError: cannot assign to None
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: '(' was never closed
Different messages - from Python
3.7: SyntaxError: can't assign to function call 3.8: SyntaxError: cannot assign to function call
3.10: SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.7: SyntaxError: invalid token 3.8: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Different messages - from Python
3.9: SyntaxError: unexpected EOF while parsing 3.10: SyntaxError: '[' was never closed
Different explanation - by Friendly-traceback
3.9: Python tells us that it reached the end of the file and expected more content. I will attempt to be give a bit more information. The opening square bracket `[` on line 5 is not closed. 5: return [1, 2, 3, ^ 3.10: The opening square bracket `[` on line 5 is not closed. 5: return [1, 2, 3, ^
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: did you forget parentheses around the comprehension target?
Different messages - from Python
3.7: SyntaxError: can't delete keyword 3.8: SyntaxError: cannot delete True
Different messages - from Python
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: SyntaxError: invalid syntax
3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different explanation - by Friendly-traceback
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: It looks like you were trying to declare that `start` was a variable using the word `var`. However, even if you remove `var`, there would still be some some syntax errors.
3.10: It looks like you were trying to declare that `var` was a variable using the word `var`. However, even if you remove `var`, there would still be some some syntax errors.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
Different explanation - by Friendly-traceback
3.7: You likely used an assignment operator `=` instead of an equality operator `==`. 3.8: You used an assignment operator `=`; perhaps you meant to use an equality operator, `==`, or the walrus operator `:=`.
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: unmatched ']'
Different explanation - by Friendly-traceback
3.7: The closing square bracket `]` on line 3 does not match anything. 3: 3]] ^ 3.8: The closing square bracket `]` on line 3 does not match anything.
Different explanation - by Friendly-traceback
3.6: `something` is not a valid feature of module `__future__`. The available features are `nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals, barry_as_FLUFL, generator_stop`. 3.7: `something` is not a valid feature of module `__future__`. The available features are `nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals, barry_as_FLUFL, generator_stop, annotations`.
Different explanation - by Friendly-traceback
3.6: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.6.8. 3.7: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.7.8.
3.8: `/` indicates that the previous arguments in a function definition are positional arguments. `*arg` must appear after `/` in a function definition.
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different explanation - by Friendly-traceback
3.7: You are likely trying to assign a value within an f-string. This is not allowed. 3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different messages - from Python
3.9: IndentationError: expected an indented block 3.10: IndentationError: expected an indented block after 'if' statement on line 3
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: unmatched '}'
Different explanation - by Friendly-traceback
3.7: The closing curly bracket `}` on line 6 does not match anything. 6: 3, 4,}} ^ 3.8: The closing curly bracket `}` on line 6 does not match anything.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: SyntaxError: can't assign to operator 3.8: SyntaxError: cannot assign to operator
3.10: SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: '(' was never closed
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to set display
3.10: SyntaxError: cannot assign to set display here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid decimal literal
Different messages - from Python
3.7: SyntaxError: assignment to keyword 3.8: SyntaxError: cannot assign to __debug__
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to dict display
3.10: SyntaxError: cannot assign to dict literal here. Maybe you meant '==' instead of '='?
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: invalid digit '8' in octal literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid imaginary literal
Different messages - from Python
3.7: SyntaxError: can't assign to generator expression 3.8: SyntaxError: cannot assign to generator expression
Different explanation - by Friendly-traceback
3.6: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.6.8. 3.7: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.7.8.
3.8: `/` indicates that the previous arguments in a function definition are positional arguments. `*arg` must appear after `/` in a function definition.
Different messages - from Python
3.7: SyntaxError: invalid token 3.8: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid imaginary literal
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different explanation - by Friendly-traceback
3.6: You are likely using a 'debug' syntax of f-strings introduced in Python version 3.8. You are using version 3.6. 3.7: You are likely using a 'debug' syntax of f-strings introduced in Python version 3.8. You are using version 3.7.
3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different messages - from Python
3.7: SyntaxError: keyword can't be an expression 3.8: SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
Different explanation - by Friendly-traceback
3.7: You likely called a function with a named argument: a_function(invalid=something) where `invalid` is not a valid variable name in Python either because it starts with a number, or is a string, or contains a period, etc. 3.8: One of the following two possibilities could be the cause: 1. You meant to do a comparison with == and wrote = instead. 2. You called a function with a named argument: a_function(invalid=...) where `invalid` is not a valid identifier (variable name) in Python either because it starts with a number, or is a string, or contains a period, etc.
Different explanation - by Friendly-traceback
3.6: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.6.8. 3.7: `/` indicates that the previous arguments in a function definition are positional arguments. This symbol can only be used with Python versions 3.8.0 or newer. You are using Python version 3.7.8.
3.8: You can only use `/` once in a function definition.
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: closing parenthesis ']' does not match opening parenthesis '(' on line 2
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to literal
3.10: SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
Different explanation - by Friendly-traceback
3.6: When using a `from __future__ import` statement, you must import specific named features. The available features are `nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals, barry_as_FLUFL, generator_stop`. 3.7: When using a `from __future__ import` statement, you must import specific named features. The available features are `nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals, barry_as_FLUFL, generator_stop, annotations`.
Different messages - from Python
3.8: SyntaxError: keyword argument repeated 3.9: SyntaxError: keyword argument repeated: ad
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid imaginary literal
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different explanation - by Friendly-traceback
3.6: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.6. 3.7: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.7.
3.8: Either not a SyntaxError for this Python version, or case excluded for some other reason.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different explanation - by Friendly-traceback
3.9: A function definition statement must end with a colon. You wrote `;` instead of a colon. 3.10: Python expected a colon at the position indicated. You wrote `;` instead of a colon.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.7: SyntaxError: can't assign to literal 3.8: SyntaxError: cannot assign to literal
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: expected ':'
Different explanation - by Friendly-traceback
3.9: A function definition statement must end with a colon. 3.10: You wrote a statement beginning with `def` but forgot to add a colon `:` at the end.
Different messages - from Python
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: SyntaxError: invalid syntax
3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different explanation - by Friendly-traceback
3.7: Either not a SyntaxError for this Python version, or case excluded for some other reason. 3.8: It looks like you were trying to declare that `start` was a variable using the word `var`. If you remove `var`, you will have a valid Python statement.
3.10: It looks like you were trying to declare that `var` was a variable using the word `var`. If you remove `var`, you will have a valid Python statement.
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid syntax. Perhaps you forgot a comma?
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?
Different explanation - by Friendly-traceback
3.9: You likely used an assignment operator `=` instead of an equality operator `==`. 3.10: You wrote an expression that includes some mathematical operations on the left-hand side of the equal sign which should be only used to assign a value to a variable.
Different messages - from Python
3.7: SyntaxError: invalid syntax 3.8: SyntaxError: cannot use assignment expressions with literal
Different explanation - by Friendly-traceback
3.6: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.6. 3.7: You appear to be using the operator `:=`, sometimes called the walrus operator. This operator requires the use of Python 3.8 or newer. You are using version 3.7.
3.8: You cannot use the augmented assignment operator `:=`, sometimes called the walrus operator, with literals like `"word"`. You can only assign objects to identifiers (variable names).
Different messages - from Python
3.7: SyntaxError: can't delete function call 3.8: SyntaxError: cannot delete function call
Different messages - from Python
3.9: SyntaxError: invalid syntax 3.10: SyntaxError: invalid decimal literal