explosion / explosion/spaCy

Error: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Open
#13,985 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
33.9k
Forks
4.7k
Avg merge
3m
Merged PRs (30d)
1

Description

## How to reproduce the behaviour
import en_core_sci_sm
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/en_core_sci_sm/__init__.py", line 2, in
from spacy.util import load_model_from_init_py, get_model_meta
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/__init__.py", line 6, in
from .errors import setup_default_warnings
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/errors.py", line 3, in
from .compat import Literal
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/compat.py", line 39, in
from thinc.api import Optimizer # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/api.py", line 1, in
from .backends import (
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/backends/__init__.py", line 17, in
from .cupy_ops import CupyOps
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/backends/cupy_ops.py", line 16, in
from .numpy_ops import NumpyOps
File "thinc/backends/numpy_ops.pyx", line 1, in init thinc.backends.numpy_ops
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Same error also happens with:

python -m spacy info --markdown

Traceback (most recent call last):
File "", line 189, in _run_module_as_main
File "", line 148, in _get_module_details
File "", line 112, in _get_module_details
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/__init__.py", line 6, in
from .errors import setup_default_warnings
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/errors.py", line 3, in
from .compat import Literal
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/spacy/compat.py", line 39, in
from thinc.api import Optimizer # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/api.py", line 1, in
from .backends import (
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/backends/__init__.py", line 17, in
from .cupy_ops import CupyOps
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/thinc/backends/cupy_ops.py", line 16, in
from .numpy_ops import NumpyOps
File "thinc/backends/numpy_ops.pyx", line 1, in init thinc.backends.numpy_ops
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

## Your Environment

* Operating System: MacOS (26.5.1 (25F80)
* Python Version Used: 3.11.14
* spaCy Version Used: 3.6.1 or 3.7.5
* Environment Information: virtual env created with uv

Previous discussions:
https://github.com/explosion/thinc/issues/939
https://github.com/explosion/spaCy/issues/13875

I get the same error as described in the github issues above. For me this happens when trying to import either of the two English dictionary versions below.
en-core-sci-sm==0.5.3 (from https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.3/en_core_sci_sm-0.5.3.tar.gz)
en-core-sci-sm==0.5.4 (from https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.4/en_core_sci_sm-0.5.4.tar.gz)
with thinc versions thinc==8.1.12 or thinc==8.2.4 and numpy==2.4.6

Contributor guide

Open the contributing guide

Research direction

Reproduce the import of en_core_sci_sm and `python -m spacy info --markdown` in the reported Python 3.11.14 environment with spaCy, thinc, and numpy versions listed in the issue. Start by comparing the compatibility reports in thinc#939 and spaCy#13875; done means the model imports and the spaCy information command runs without the binary incompatibility error.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.