Maria_DS
Maria_DS

Reputation: 51

Error while loading spacy [E002] Can't find factory for 'tok2vec'

I can't seem to find a solution for this problem anywhere:

I'm trying to use spacy's medium english model: en_core_web_md

As downloading spacy through my command line doesn't work at all, I downloaded the model to my directory and proceeded to call it out:

import spacy
nlp = spacy.load('en_core_web_md-3.1.0')

However, I keep getting the following error:

KeyError: "[E002] Can't find factory for 'tok2vec'. This usually happens when spaCy calls `nlp.create_pipe` with a component name that's not built in - for example, when constructing the pipeline from a model's meta.json. If you're using a custom component, you can write to `Language.factories['tok2vec']` or remove it from the model meta and add it 
via `nlp.add_pipe` instead."

The small spacy model en_core_web_sm works perfectly fine but I need a larger model to perform the calculations I need.

pip 21.1.3 
spaCy version    2.3.5       
Platform         Windows-10-10.0.19041-SP0
Python version   3.9.5

Upvotes: 5

Views: 10079

Answers (2)

Narayanan_Symbiance
Narayanan_Symbiance

Reputation: 21

This happens because of the "en_core_web_" package version use lower version like 2.3.1 or 2.1.0

Upvotes: 0

polm23
polm23

Reputation: 15633

The version of spaCy you're using doesn't match the version of the model you're using. The first two numbers should be the same.

spaCy version    2.3.5
en_core_web_md-3.1.0

I'd recommend you upgrade spaCy to 3.1.1, then the model you have should work.

Note that sometimes people get the old version 2.3.5 installed when they use the conda base env. Try using a clean conda env and following the quickstart (or just not using conda).

Upvotes: 3

Related Questions