Valueerror not enough values to unpack expected 2 got 1
One common error that programmers encounter is the ValueError: Not Enough Values to Unpack (Expected 2, Got 1). This error typically occurs if we are trying to unpack values from …
itsourcecode.com hosts 100+ documented fixes for Python ValueError messages: the error class Python raises when a function or operation receives an argument of the right type but inappropriate value. Most ValueErrors come from data libraries: pandas with DataFrame indexing, NumPy with array shapes, scikit-learn with input dimensions, TensorFlow with tensor conversion, and matplotlib with axis coordinates. Browse by library or use the search bar to find your exact error.
What is a Python ValueError?
A ValueError is raised when a function receives an argument of the correct type but with an invalid value. For example, int("abc") raises ValueError because "abc" is a string (the right type for int()) but isn’t convertible to an integer. ValueError is distinct from TypeError (wrong type entirely) and from AttributeError (object doesn’t have that method). The data science stack (pandas, NumPy, scikit-learn) raises ValueErrors prolifically because they validate data shape and content extensively.
How to debug any ValueError in 4 steps
Read the full message. ValueError messages are usually descriptive, they tell you what value was invalid and what was expected (e.g., "could not convert string to float: 'N/A'", "expected 2d array, got 1d array instead").
Print the input that triggered the error. Add print(x, type(x), len(x) if hasattr(x, '__len__') else 'scalar') before the failing line. Most ValueErrors are about shape, length, or specific content.
Check the library’s expected input format. sklearn expects 2D arrays for features; pandas reindex expects unique labels; NumPy operations require compatible shapes. The docs for the failing function are usually clear about constraints.
For “could not convert” errors, validate the data first. Filter out NaN, infinity, empty strings, or invalid format values before passing to the function. Use pd.to_numeric(x, errors='coerce') for cleaning numeric columns.
Featured ValueError fixes by library
🐼 pandas (DataFrame, reindex, NaT, openpyxl)
pandas ValueErrors usually come from index conflicts, NaN handling, or version mismatches with Excel engines.
Cannot insert ‘level_0’, already exists, 2026 Guide
Cannot reindex on an axis with duplicate labels, 2026 Guide
DataFrame constructor not properly called
Unknown engine: openpyxl (Excel reader)
Cannot convert non-finite values (NA or inf) to integer
NaTType does not support strftime, 2026 Guide
No engine for filetype, 2026 Guide
Unconverted data remains, 2026 Guide
🔢 NumPy (shape, dimensional, argmax)
NumPy ValueErrors are usually array-shape problems, you’re trying to operate on arrays whose dimensions don’t match what the operation expects.
Object too deep for desired array, 2026 Guide
Need at least one array to concatenate, 2026 Guide
Attempt to get argmax of an empty sequence
Indices for endog and exog are not aligned (statsmodels)
Data must be 1-dimensional, 2026 Guide
🤖 scikit-learn (X and Y, classes, vocabulary)
sklearn ValueErrors are about input validation, wrong dimensions, wrong number of classes, or empty inputs.
X and Y must be the same size, 2026 Guide
Expected 2D array, got 1D array instead
Empty vocabulary; perhaps the documents only contain stop words
🧠 TensorFlow & Keras (cardinality, tensors)
Data cardinality is ambiguous
Can’t convert non-rectangular Python sequence to tensor
📊 matplotlib (axis, coordinates, sample size)
Coordinate ‘right’ is less than ‘left’
Sample larger than population or is negative, 2026 Guide
📷 PIL / Pillow (images)
Images do not match (same mode/size required)
🕐 datetime (strptime format mismatch)
The most common datetime ValueError is “unconverted data remains”, your format string doesn’t match the date string exactly.
Unconverted data remains, 2026 Guide
🐍 Python built-ins (int, float, unpack, regex)
Invalid literal for int() with base 10
Not enough values to unpack (expected 2, got 1)
Circular reference detected (json.dumps)
Pattern contains no capture groups (re.findall)
2026 Updated Guides: featured ValueError fixes
These guides were rewritten or expanded in 2026 with current library versions, minimal reproductions, and 3-4 alternative fixes each.
Empty vocabulary, perhaps the documents only contain stop words: sklearn CountVectorizer
Cannot insert ‘level_0’, already exists: pandas reset_index
Object too deep for desired array: NumPy
X and Y must be the same size: matplotlib / sklearn
Cannot reindex on an axis with duplicate labels: pandas
Sample larger than population or is negative: random.sample
Need at least one array to concatenate: np.concatenate
NaTType does not support strftime: pandas datetime
Data must be 1-dimensional: pandas Series
Unconverted data remains: datetime.strptime
No engine for filetype: pandas read_excel
Related error categories
ValueError is one of 10 hubs in our Python & JavaScript error reference cluster, 980+ documented fixes total. If your error isn’t a ValueError, jump to the right hub below:
TypeError Reference, 220+ Python & JS TypeError fixes
ModuleNotFoundError Reference, 198+ Python import errors
AttributeError Reference, 173+ “object has no attribute X” fixes
ImportError Reference, 67+ “cannot import name X from Y” fixes
NameError Reference, 49+ Python “name X is not defined” fixes
RuntimeError Reference, 49+ PyTorch CUDA, asyncio, Flask runtime errors
SyntaxError Reference, 48+ Python & JavaScript parsing errors
ReferenceError Reference, 34+ JavaScript “is not defined” fixes
HTTP Error Reference, 35+ HTTP status code fixes
Python Tutorial, beginner-to-intermediate Python lessons
About this ValueError reference
This ValueError reference has been built since 2015 by PIES Information Technology Solutions in Binalbagan, Negros Occidental, Philippines. Every post comes from a real error encountered in production code. Used by 12,000+ Python developers monthly across the Philippines, India, the United States, and beyond. If your ValueError isn’t here, send the full traceback to our contact form and we’ll add it.
One common error that programmers encounter is the ValueError: Not Enough Values to Unpack (Expected 2, Got 1). This error typically occurs if we are trying to unpack values from …
The error message “valueerror check_hostname requires server_hostname” typically occurs when working with Python’s ssl module, which provides SSL (Secure Sockets Layer) and TLS (Transport Layer Security) protocols for secure network …
In the world of programming and software development, encountering errors is inevitable. One of the errors that developers often encounter is the valueerror max arg is an empty sequence. This …
When working with programming languages like Python, encountering errors is a common existence. One of the errors that often encountered by developers is the ValueError: Invalid literal for int with …
In Python programming, relative imports are a proper way to import modules or packages within the same project directory. However, sometimes you may encounter a ValueError: Attempted relative import in …
In this article, we will learn the error valueerror: unknown label type: ‘continuous’ in Python programming. Also, we will provide examples, solutions, and answers to frequently asked questions related to …
Have you ever encountered the ValueError embedded null byte error while working on your programming code? Don’t worry! In this article, we will explain this error and provide you with …
If you are working with formatting operations, you might encounter the error message valueerror invalid format specifier. This error occurs when the formatting specifier used in the string does not …
This Valueerror: attempted relative import in non package error typically occurs when we attempt to perform a relative import in a Python module that is not part of a package. …
One of the common errors might encounter of all developers is valueerror: malformed node or string error message. If you’ve come across an error message, Don’t panic! In this article, …
If you are working with multidimensional arrays or data structures, you may encounter an error message which is ValueError: Cannot Index with Multidimensional Key. This error occurs when we are …
The error message ValueError: unknown format code ‘f’ for object of type ‘str’ typically occurs when trying to use a string formatting code which is not compatible with the data …
In running a system program, encountering errors is a common issue. These errors sometimes can be mystifying and may require a comprehensive understanding of the code to identify and resolve …