explosion / explosion/spaCy

Expected 96 from C header, got 88 from PyObject when importing "en_core_sci_sm" version 0.5.4

Open
#13,998 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
The issue occurs during import of "en_core_sci_sm" version 0.5.4. The error trace is below. The issue seems to be related to numpy. This error has occurred previously and seems to be recurring whenever the numpy version changes. The main problem seems to be that "en_core_sci_sm" depends on an older spaCy version which runs on a numpy 2.x that has this error.

Traceback (most recent call last):
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/bin/pipeline_predict", line 4, in
from pipeline.predicting.run_local_inference_for_ner import main
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/pipeline/predicting/run_local_inference_for_ner.py", line 12, in
from pipeline.predicting.inference_tools import (
File "/Users/melaniev/Documents/code/PDBe_public_repos/IUCr-annotation-pipeline/.venv/lib/python3.11/site-packages/pipeline/predicting/inference_tools.py", line 2, in
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

## Your Environment

* Operating System: Tahoe 26.5.2
* Python Version Used: 3.11.14
* spaCy Version Used: 3.7.5
* Environment Information: numpy==2.4.6; onnx==1.22.0; onnxruntime==1.27.0; optimum==2.2.0; transformers==5.14.1; torch==2.13.0; tokenizers==0.22.2; pandas==3.0.3; beautifulsoup4==4.15.0

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the import through the pipeline_predict entry point using the listed Python, spaCy, NumPy, and en_core_sci_sm versions. Inspect the traceback path through spacy/compat.py, thinc/backends/cupy_ops.py, and thinc/backends/numpy_ops.pyx, then verify the en_core_sci_sm and spaCy dependency relationship. Done means the compatibility outcome and a reliable import result are established.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.