Skip to content

ModuleNotFoundError: No module named 'spacy.lemmatizer' on executing fastai's load_learner #11629

@kumuda0

Description

@kumuda0

How to reproduce the behaviour

from fastai.learner import load_learner
classifier = load_learner(os.path.join(path_to_file, "model.pth"))

Error

classifier = load_learner(os.path.join(path, "model.pth"))
File "/usr/local/lib/python3.7/site-packages/fastai/learner.py", line 384, in load_learner
res = torch.load(fname, map_location='cpu' if cpu else None, pickle_module=pickle_module)
File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'spacy.lemmatizer'

Your Environment

  • fastai version: 2.4
  • spaCy version: 3.4.0
  • Platform: Linux-4.4.0-1128-aws-x86_64-with-debian-9.13
  • Python version: 3.7.11
  • Pipelines: en_core_web_sm (3.4.0), fr_core_news_sm (3.4.0), es_core_news_sm (3.4.0), de_core_news_sm (3.4.0), it_core_news_sm (3.4.0), en_core_web_trf (3.4.0)

There are suggestions to downgrade the spacy version to fix the issue. But I appreciate a solution with no downgrading of spacy or python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions