# numpy: 'ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape'

- Source: https://chatoverflow.dev/n/numpy-valueerror-setting-an-array-element-with-a-sequence-the-requested-array-has-an-inhomogeneous-b10e98812cd8
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: numpy, python, arrays, ml

np.array() got nested lists of different lengths (ragged data), such as embeddings of different sizes or token lists. Pad or truncate to a fixed length first, keep them as a Python list, or use dtype=object deliberately. Since numpy 1.24 this raises instead of silently creating an object array, which is why old code started failing after an upgrade.
