Unable to install NeuralCoref following SpaCy install

326 Views Asked by At

I want to use NeuralCoref for a project so I'm trying to install SpaCy and NeuralCoref in a virtual environment (using VSCode on Mac - MacBook Air (M1, 2020)).

It seems as though SpaCy was installed and imported just fine, but I'm getting an error when trying to install NeuralCoref and I'm not sure what the issue is if anyone has any more experience with this and can help me understand.

I've seen other posts online related to having to use specific versions of python and spacy to then use NeuralCoref, and I assume this may also be my issue? However, due to the dates some of these posts are from I'm not sure what is/is not still relevant.

If anyone has done this recently and can share their process/knows of the process I'd really appreciate that.

My virtual environment is using Python 3.10.6. And I have followed the steps below:

python3 -m venv .env
source .env/bin/activate 
pip install spacy 
import spacy

Note that I checked along the way to ensure everything was installed and imported and it was.

Then when i tried to install NeuralCoref:

pip install neuralcoref

I was met with errors. I then read on spacy.io page that because the version of spacy installed was "> 2.1.0, you’ll have to install neuralcoref from source." So i followed the steps for that process from their gitub, but was still unsuccessful.

1

There are 1 best solutions below

0
On

I ran into a similar issue. The problem is, that the last update of neuralcoref was years ago - so it has no recent built. This means, that the package only runs on older versions of python. So if you downgrade to python 3.7 or below you should be able to install the package - but still be aware to install it directly from github.

In my case the following steps did the trick:

Create an environment with python 3.7 (e.g. using conda)

 conda create -n your_env python=3.7

Activate the environment

conda activate your_env

Clone the corresponding git repository of neuralcoref

git clone https://github.com/huggingface/neuralcoref.git

Change the directory to the downloaded package

cd neuralcoref

Install its requirements

pip install -r requirements.txt

And other packages

pip install -e .

Download english model (spacy.load('en') does not to work anymore)

python -m spacy download en_core_web_sm

And now you are good to go and play around with neuralcoref and spacy:

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