'importing Example from Spacy.training module

Hi I am trying to import Example class from Spacy.training module. I am trying exact code as in documentation.

from spacy.training import Example

But I am getting "ModuleNotFoundError: No module named 'spacy.training'" How can i import Example class now.



Solution 1:[1]

Example was introduced in spacy version 3.

Link to Example https://spacy.io/api/example#_title

You can check the current version of your spacy with this command on your Jupyter cell:

!pip show spacy  

OR

spacy.__version__

Once you check the version, you can update to a latest version by:

!pip install -U spacy

Once, you get spacy 3 your problem will be resolved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1