ModuleNotFoundError: No module named 'flair'

5.9k Views Asked by At

I have installed flair library via the following command

!pip install flair

but when i tries to import it, it will generate error like "ModuleNotFoundError: No module named 'flair'"

Code:

import torch
import numpy as np
from flair.data import Sentence
from flair.embeddings import TransformerDocumentEmbeddings
2

There are 2 best solutions below

0
On BEST ANSWER

install via the following command make sure you use --user option otherwise you will get a permission error in windows 10.

!pip install --user flair

after install flair you have to restart kernel in jupyter notebook

0
On

For the case if anyone find this thread and had the same problem: flair is installed, but python says: ModuleNotFoundError: No module named 'flair.data'; 'flair' is not a package

In my case the problem was a noob error: the name of my script has the same name like the package: flair.py. After renaming my script to flair_ner.pyeverything works fine.