Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: spacy.strings.StringStore size changed, may indicate binary incompatibility. Expected 80 from C header, got 64 from PyObject #310

Open
zaynxalic opened this issue May 7, 2021 · 15 comments

Comments

@zaynxalic
Copy link

I am using python ==3.8.3, spacy==3.0.5, neuralcoref ==4.0.
These libraries are successfully installed.
When running the code

import spacy
import neuralcoref

nlp = spacy.load('en')
neuralcoref.add_to_pipe(nlp)
doc1 = nlp('My sister has a dog. She loves him.')
print(doc1._.coref_clusters)

I get the error.

Traceback (most recent call last):
File "d:/Comp4550/xxxxxxxxxxxxxxx/code/analysis/co-reference.py", line 2, in
import neuralcoref
File "D:\python3.8.3\lib\site-packages\neuralcoref_init_.py", line 14, in
from .neuralcoref import NeuralCoref
File "strings.pxd", line 23, in init neuralcoref.neuralcoref
ValueError: spacy.strings.StringStore size changed, may indicate binary incompatibility. Expected 80 from C header, got 64 from PyObject

I search the error code in google and I get this from stackoverflow [https://stackoverflow.com/questions/67041981/valueerror-spacy-strings-stringstore-size-changed-may-indicate-binary-incompat] . It suggests me to downgrade the python version. However, python version cannot be changed due to the particular project. I wonder that if there exists a way for me to successfully run the test code.
By the way, I also try pip uninstall neuralcoref, pip install neuralcoref --no-binary neuralcoref. The problem is still not resolved. If anyone can solve my problem, I am really appreciate that.

@vikingspy
Copy link

vikingspy commented May 8, 2021

Also having this issue; I'm using a Win10 PC in a conda environment with config:

  • python == 3.7.10
  • spacy == 3.0.6
  • neuralcoref == 4.0
  • cython == 0.29.23
  • numpy == 1.20.2

When I run the code:

from spacy.lang.en import English
import spacy
import neuralcoref
nlp = English()
neuralcoref.add_to_pipe(nlp)

I get the error:

ValueError                                Traceback (most recent call last)
<ipython-input-1-8e5edb230c15> in <module>
      1 from spacy.lang.en import English
      2 import spacy
----> 3 import neuralcoref
      4 nlp = English()
      5 # nlp.add_pipe("sentencizer")

~\Anaconda3\envs\spacy_work\lib\site-packages\neuralcoref\__init__.py in <module>
     12 warnings.filterwarnings("ignore", message="spacy.strings.StringStore size changed,")
     13 
---> 14 from .neuralcoref import NeuralCoref
     15 from .file_utils import NEURALCOREF_MODEL_URL, NEURALCOREF_MODEL_PATH, NEURALCOREF_CACHE, cached_path
     16 

strings.pxd in init neuralcoref.neuralcoref()

ValueError: spacy.strings.StringStore size changed, may indicate binary incompatibility. Expected 80 from C header, got 64 from PyObject

What I tried:

  • Performed the binary install mentioned in the readme, got the same error message.
  pip uninstall neuralcoref
  pip install neuralcoref --no-binary neuralcoref  
  • Downgraded to spacy 3.0.0. Same error message.

Any help would be very much appreciated!

@TY-Cheng
Copy link

same here... can't import why?
thx!

image

@correia-marcos
Copy link

correia-marcos commented May 17, 2021

I've tried so many things. Seeing others issues I came to realized neuralcoref doesn't work in spacy v3 (see [stackoverflow] also (https://stackoverflow.com/questions/57008612/kernel-died-when-running-neuralcoref)).
The problem for me now is actually how to download spacy pipeline for v2 versions? Seems stupidly easy, but I can't find in the documentation.

@manekiyong
Copy link

manekiyong commented May 26, 2021

Hey all, as @correia-marcos mentioned, I figured that there seems to be some compatibility issue between spacy v3 and neuralcoref. Here are the steps I did to make it work:

  1. Setup a python3.7 on conda env and conda install -c anaconda git
  2. As per stated in README.md,
git clone https://github.com/huggingface/neuralcoref.git
cd neuralcoref
pip install -r requirements.txt
pip install -e .
  1. At this stage, your spacy version should be 2.3.x (verify using pip show spacy), because the requirements.txt did explicitly stated that spacy version has to be <3.0.0. Hence, DO NOT execute pip install -U spacy, which would upgrade your spacy version to beyond 3.0.0.
  2. Execute python -m spacy download en to obtain your English Model.

Summary of key item versions:

Python==3.7.10
spacy==2.3.5
neuralcoref==4.0

Hope this helped! :)

@vikingspy
Copy link

Thanks, @manekiyong -- I guess I was hoping we could get the compatibility issue fixed so we could use both neuralcoref and the fancy new features of spacy 3.0.

But again, thank you for taking the time to respond with such clear instructions.

@baber-sos
Copy link

I was also encountering the spacy.strings.StringSize issue as well with spacy 3.0. I downgraded to spacy 2.1.0 but encountered the following error:
"spacy.vocab.Vocab size changed, may indicate binary incompatibility. Expected 120 from C header, got 112 from PyObject"
So far have tried with python 3.6.9/3.7.10 with spacy versions 2.1.x and 2.3.x but the error persists. If anyone has any insights they would be welcome.

@baber-sos
Copy link

baber-sos commented Jun 30, 2021

Issue seems to have been created by one of the recent commits. I used feb 2020 version of the neuralcoref library (commit '73d07e97fe') and it seems to have been installed at least. Leaving it here as it might help someone else.
Works with both python versions 3.6.9 and 3.7.10.

@polm
Copy link
Contributor

polm commented Jul 1, 2021

Just want to pop in here and note that neuralcoref is not compatible with spaCy v3 as indicated in #295 (comment). We're working on a new coref model with a different architecture for v3.

@avijay6
Copy link

avijay6 commented Nov 26, 2021

I think I figured out the solution to this
I downgraded my spacy to v2.1.0 and the error was gone. Please try and let me know if it worked for you.
Python version 3.7.4 and neuralcoref v4.0

@fbottazzoli
Copy link

fbottazzoli commented Mar 28, 2022

I followed the steps suggested by @manekiyong but still get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9384\1435153998.py in <module>
      4 
      5 # Add neural coref to SpaCy's pipe
----> 6 import neuralcoref
      7 neuralcoref.add_to_pipe(nlp)
      8 

~\anaconda3\lib\site-packages\neuralcoref\__init__.py in <module>
     12 warnings.filterwarnings("ignore", message="spacy.strings.StringStore size changed,")
     13 
---> 14 from .neuralcoref import NeuralCoref
     15 from .file_utils import NEURALCOREF_MODEL_URL, NEURALCOREF_MODEL_PATH, NEURALCOREF_CACHE, cached_path
     16 

strings.pxd in init neuralcoref.neuralcoref()

ValueError: spacy.strings.StringStore size changed, may indicate binary incompatibility. Expected 80 from C header, got 64 from PyObject

Name: spacy Version: 2.3.7
Name: neuralcoref Version: 4.0

@manekiyong
Copy link

Hey @fbottazzoli

I just replicated the steps and verified that the method still works. You may wish to check whether you are working on the correct Python environment. To ensure that your script is running the right version of spacy, you can do the following:

import spacy
print(spacy.__version__)

If the version is correct and problem still persists, you may consider restarting on a clean environment.

Also, in my original post, I indicated that I was using Python 3.7. I just verified that it works on 3.9 (specifically, 3.9.11) as well.

@fbottazzoli
Copy link

Hi @manekiyong

I tried to reproduce again the steps you listed in a new environment with Python 3.9.11.

When running pip install -e . at point 2jup, the following error occurs:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
textacy 0.11.0 requires spacy>=3.0.0, but you have spacy 2.3.7 which is incompatible.
it-core-news-sm 3.2.0 requires spacy<3.3.0,>=3.2.0, but you have spacy 2.3.7 which is incompatible.
en-core-web-sm 3.2.0 requires spacy<3.3.0,>=3.2.0, but you have spacy 2.3.7 which is incompatible.

I then tried to run the following code in a Jupyter notebook:

# Load your usual SpaCy model (one of SpaCy English models)
import spacy
nlp = spacy.load('en')

# Add neural coref to SpaCy's pipe
import neuralcoref
neuralcoref.add_to_pipe(nlp)

# You're done. You can now use NeuralCoref as you usually manipulate a SpaCy document annotations.
doc = nlp(u'My sister has a dog. She loves him.')

doc._.has_coref
doc._.coref_clusters

but the kernel always dies when running: doc = nlp(u'My sister has a dog. She loves him.') and unfortunately I'm not able to get any errror message.

Francesca

@manekiyong
Copy link

Hey @fbottazzoli,

I suspect you have residual files that your environment is reading from that is causing all these. The version of spacy and neuralcoref used does not require the textacy.

Furthermore, there might be compatibility issues with the version of the language model that you are using. Based on the installation steps on a clean environment, en_core_web_sm installed should be version 2.3.1, and it_core_news_sm installed should be version 2.3.0.

@fbottazzoli
Copy link

Hi @manekiyong ,
I succeded in installing the module and running it. The only thing I think I did differently is the conda environment creation: this time I made it from command line, while previously from Anaconda Navigator.
Thank you for your help.
Francesca

@LaineWang
Copy link

大家好,作为@correia-marcos提到,我认为 spacy v3 和 neurocoref 之间似乎存在一些兼容性问题。以下是我为使其工作而采取的步骤:

  1. 在 conda env 上设置 python3.7 和conda install -c anaconda git
  2. 如中所述README.md
git clone https://github.com/huggingface/neuralcoref.git
cd neuralcoref
pip install -r requirements.txt
pip install -e .
  1. 在这个阶段,你的 spacy 版本应该是2.3.x(验证使用pip show spacy),因为requirements.txt确实明确指出 spacy 版本必须是<3.0.0. 因此,不要执行pip install -U spacy,这会将您的 spacy 版本升级到 Beyond 3.0.0
  2. 执行python -m spacy download en以获得您的英文模型。

关键项目版本摘要:

Python==3.7.10
spacy==2.3.5
neuralcoref==4.0

希望这有帮助!:)

thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants