Yet another "Can't find model" question #13639
Replies: 1 comment
-
I solved this problem by writing this pair of small utility functions: from spacy.language import Language as SpacyLanguage
import spacy.util as spacy_util
def find_path_to_site_packages() -> str | None:
for p in sys.path:
if "site-packages" in p:
return p
return None
def load_spacy_model(model: str) -> SpacyLanguage:
version = spacy_util.get_package_version(model)
cfg_dir = f"{model}-{version}"
spacy_model_path = os.path.join(
find_path_to_site_packages(),
model,
cfg_dir)
return spacy.load(spacy_model_path) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to load the model
fr_dep_news_trf
inside a of a scrapy pipeline step. I have runpython -m spacy download fr_dep_news_trf
with the relevant virtualenv activated and verified that a dir calledsite-packages/fr_dep_news_trf
exists in that virtualenv.python -m spacy info
gives this:python -m spacy validate
gives this:python -m pip list
gives:Most questions of this genre seem to boil down to IDE interference or some virtualenv problem. I'm only using the terminal, but I suppose it could still be a virtualenv problem. That said, I'm really at a loss for what I've messed up here. Would really appreciate any help.
Beta Was this translation helpful? Give feedback.
All reactions