← All Kali Issues
Python

SyntaxError invalid syntax

S System Medium

🔴 Error Message

SyntaxError: invalid syntax running Python 2 script

📖 What This Means

Python 2 script being run with Python 3 interpreter.

🔧 Step-by-Step Fix

  1. Use python2: python2 script.py
  2. Install python2: sudo apt install python2
  3. Convert script: 2to3 script.py
  4. Check shebang line: #!/usr/bin/env python3