ValueError: invalid literal for int() with base 10: 'abc'
int() received a string that isn’t a whole number — empty, decimal, whitespace or text.
Seen on:
Python
Meaning
int() only accepts digit strings (optionally signed). "3.5", "", "1,000" and "12a" all fail. The quoted value in the message is exactly what was passed.
Common causes
- Empty string from input/CSV
- Decimal string passed to int()
- Thousands separators or currency symbols
- Header row parsed as data
⚡ Quick fix
- Strip and validate before converting
- Use int(float(s)) for decimal strings when truncation is intended
- Remove separators: s.replace(',', '')
- Catch ValueError and report the bad row
Detailed fix by platform
Python
- python
try: qty = int(row["qty"].strip()) except ValueError: errors.append(row)
How to diagnose
- Value — What string is quoted in the message?
- Source — Form, CSV, env var?
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026