Search code examples
nlpspacynamed-entity-recognition

Getting a Spacy error: No module named 'spacy.pipeline.pipes'; 'spacy.pipeline' is not a package


I'm trying to test a model that is working in another machine, but when I try to import it to my notebook, I get this error: ModuleNotFoundError: No module named 'spacy.pipeline.pipes'; 'spacy.pipeline' is not a package

We have installed: Spacy 2.0.18 (Frozen version, Not updatable whatsoever)

And I'm importing:

import spacy
import thinc
import unidecode
import nltk
from spacy.vocab    import Vocab
from spacy.language import Language
from spacy.lang.pt  import Portuguese
from spacy.lang.en  import English
from spacy.pipeline import EntityRecognizer
ner = EntityRecognizer(nlp.vocab)
nlp = Language(Vocab())
nlp = Portuguese()
# Load NER Model
NER_MODEL = pickle.load( open("/ner_model_v022_epoch=706_loss=09o76364626.pkl", "rb" ) )

And I get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-12-83d4770d3e3e> in <module>

---> 40 NER_MODEL = pickle.load( open("/ner_model_v022_epoch=706_loss=09o76364626.pkl", "rb" ) )

ModuleNotFoundError: No module named 'spacy.pipeline.pipes'; 'spacy.pipeline' is not a package

Any ideas why this might be happening? Already installed everything again from 0 but keeps giving me the same error.

Any help will be greatly appreciated.


Solution

  • I had this problem come up and found that switching my spacy version from spacy==2.0.18 to spacy==2.1.4 worked! Went back through their releases and spacy.pipeline.pipes isn't present until v2.1.0a8