`ValueError: too many values to unpack (expected 2)` parsing `KEY=VALUE` lines from an env file.
BeginnerTroubleshootingRuntime, file, subprocess & encoding errors
Answer
Likely causes → A value contains = (base64 strings, URLs with query strings), so line.split("=") returns more than two parts.
Diagnose → Print the failing line.
Fix → key, _, value = line.partition("=") or line.split("=", 1); skip blank lines and # comments; strip surrounding quotes.
Prevent → Use python-dotenv for env files rather than hand-written parsers.
More on Runtime, file, subprocess & encoding errors
`KeyError: 'Tags'` while processing `describe_instances` output.Beginner`TypeError: can't compare offset-naive and offset-aware datetimes` in a snapshot-age check.Beginner`UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte` reading a log file.Intermediate`UnicodeEncodeError: 'ascii' codec can't encode character '✓'` when printing in a container.Intermediate`PermissionError: [Errno 13] Permission denied: '/var/log/app/report.json'`Intermediate`OSError: [Errno 24] Too many open files` in a long-running Python service.Intermediate