unpack error Python Origin: Application & API Last updated 13 Oct 2026

ValueError: too many values to unpack (expected 2)

Tuple unpacking got more (or fewer) values than variables on the left.

Exact message you may see too many values to unpacknot enough values to unpack
Seen on: Python

Meaning

Common when iterating a dict without .items(), splitting strings with more separators than expected, or functions returning a different number of values.

Common causes

  • for k, v in dict: (missing .items())
  • line.split(",") returning more parts
  • Function returns a different tuple size

⚡ Quick fix

  1. Use for k, v in d.items()
  2. split with maxsplit: s.split(",", 1)
  3. Use star-unpacking: first, *rest = parts

Detailed fix by platform

Python

  1. key, value = line.split("=", 1)

How to diagnose

  1. Values — Expected vs actual count
  2. Source — What is being unpacked?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

AttributeError — AttributeError: 'X' object has no attribute 'y' (Python)AttributeErrorConnectionRefusedError — ConnectionRefusedError: [Errno 111] Connection refused (Python)ConnectionRefusedErrorDisallowedHost — django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'x'. You may need to add 'x' to ALLOWED_HOSTS. (Python)DisallowedHostDjango CSRF — Forbidden (403) CSRF verification failed. Request aborted. (Python)Django CSRFEvent loop is closed — RuntimeError: Event loop is closed (Python)Event loop is closedImproperlyConfigured — django.core.exceptions.ImproperlyConfigured: settings are not configured / SECRET_KEY must not be empty (Python)ImproperlyConfigurednever awaited — RuntimeWarning: coroutine 'fetch' was never awaited (Python)never awaitedunpack er…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.