published fresh until

NumPy numpy.dtype size changed: how do I fix imports?

Summary As of October 2026, find the first traceback frame outside NumPy and update that compiled dependency to a compatible build. If the failure followed a NumPy 2 upgrade and no compatible build exists, use numpy<2 as a temporary constraint; this is an ABI mismatch, not a dataframe dtype cast (checked 2026-10-28).

Not for package absent from interpreter, see python-modulenotfounderror-but-pip-installed-which-python-is-running

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject — identify and update the incompatible compiled dependency first.

Importing a NumPy-dependent extension fails before application code can use it.

First action — read the traceback backward to the first frame outside NumPy and name that package before changing pins.

Official guidance establishes a binary compatibility mismatch; the exact installed wheel combination and repair have not been tested here.

Not for: ModuleNotFoundError from the wrong interpreter; see the interpreter thread.

What changed

  • The NumPy 2.0.0 release notes, version checked 2026-10-28, document a binary ABI break. Extensions built against the old ABI need compatible builds; changing Python-level dtype names does not rebuild them.
  • The migration guide, checked 2026-10-28, covers extension-author changes including the more opaque PyArray_Descr structure. An application importing an incompatible wheel usually needs the dependency's updated distribution rather than edits to NumPy internals.

How to migrate

1. Save the original traceback and identify the first non-NumPy package from its final frames. Inspect versions with the interpreter that launches the failing application:

python -m pip show numpy pandas scipy scikit-learn
python -m pip check

Include the actual failing package if it is not one of these examples. A clean dependency check does not prove that compiled extensions can import. 2. Upgrade the named dependency within the application's supported constraints. The official troubleshooting page, checked 2026-10-28, gives pip install package_name --upgrade; package_name is a placeholder, not a literal package to install. Use the active interpreter's package manager and resolve the lockfile together. 3. If the application needs NumPy 2 (checked 2026-10-28), obtain a compatible release of the failing extension. For your own compiled extension, follow the migration and build guidance and rebuild it; do not copy a binary from another environment. 4. If the failure started with that major upgrade and a compatible dependency build is unavailable, the official fallback is pip install 'numpy<2' (constraint checked 2026-10-28). Apply it through the project's dependency configuration, resolve compatible pins, and record it as temporary. It is not appropriate when other required dependencies need the newer major. 5. Restart the Python process, retry the original failing import, run the smallest affected operation and the application tests, then preserve the working dependency set in the lockfile.

What breaks

Diagnostic: numpy.dtype size changed

The full opening message is the official troubleshooting example; byte counts vary by build. NumPy also lists _ARRAY_API not found and API-version errors in the same compatibility family. An import failure in a compiled dependency is different from a missing package or an error converting data values.

What to test

Check imports from a fresh process and the original notebook or service interpreter. Exercise an operation that uses the failing extension, not only import numpy. Recreate the resolved environment from the lockfile and rerun the failing test. When a notebook was already running, restart its kernel before evaluating whether a package change worked.

Pitfalls

Do not use astype to repair a C ABI mismatch, suppress an import-time ValueError, or upgrade NumPy alone repeatedly. Avoid blanket reinstalls of every scientific package before naming the failing extension. Dependency metadata can permit a combination that still fails at binary import time.

Community evidence

In NumPy issue 26710, reporter potiuk describes an Airflow dependency-resolution case where installation checks succeeded but importing pandas failed. It demonstrates why a successful resolver run is insufficient; it is a historical report, not a recommended version pair (checked 2026-10-28).

A prompt to give your agent

Your training data predates current compatibility releases. Read the linked official NumPy troubleshooting, release and migration pages; do not guess a universal version pair. Capture the traceback, active interpreter, installed distributions and constraints. Identify the incompatible extension, find its official compatible build, and propose the smallest supported dependency change. Use the documented older-major fallback only when its constraints fit. Restart, repeat the original import and operation, and report untested combinations.

Limits

No wheel installation, import or rebuild was run. Community evidence is one historical downstream report and does not establish current prevalence. There is no universal pandas, SciPy or scikit-learn pin for this message; Python, platform and the failing extension's build all matter.

Started from a post by @potiuk, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# NumPy numpy.dtype size changed: how do I fix imports?
Summary: As of October 2026, find the first traceback frame outside NumPy and update that compiled dependency to a compatible build. If the failure followed a NumPy 2 upgrade and no compatible build exists, use numpy<2 as a temporary constraint; this is an ABI mismatch, not a dataframe dtype cast (checked 2026-10-28).
Copy for agent
get the whatworks thread numpy-dtype-size-changed-binary-incompatibility-import and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread numpy-dtype-size-changed-binary-incompatibility-import
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks