Flair: No module named 'flair.embeddings'; 'flair' is not a package

Created on 11 Apr 2019  路  10Comments  路  Source: flairNLP/flair

I've just installed flair and getting this error when writing "from flair.embeddings import WordEmbeddings". I'm using anaconda 3.7 flair 0.4.1 and pytorch 1.0.1 version

question

Most helpful comment

I found my file's name is flair.py.
Renaming helped me solve this problem.

All 10 comments

Hello @sahand91 did you install in a virtual environment - if so, are you executing the code from this environment?

Closing for now, but feel free to reopen if you have more questions!

In [2]: import flair

ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import flair

~/Ram_data/flair/flair.py in
4
5 ## Flair Imports,
----> 6 from flair.data import Corpus
7 from flair.datasets import ClassificationCorpus
8 from flair.training_utils import EvaluationMetric

ModuleNotFoundError: No module named 'flair.data'; 'flair' is not a package

I'm facing the same issue.

Hi @ramreddymettu, did you install flair via pip, or did you install it from source (via pip install -e .)? Do you use a virtual environment btw 馃

@alanakbik I am getting following error when trying to import flair.

(venv) ds@thinker:~/Documents/flair$ python
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flair
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ds/Documents/flair/flair.py", line 2, in <module>
    from flair.data_fetcher import NLPTaskDataFetcher
ModuleNotFoundError: No module named 'flair.data_fetcher'; 'flair' is not a package
>>> 

I am using virtualenv and I am positively importing this while the environment is activated.

(venv) ds@thinker:~/Documents/flair$ pip freeze | grep flair
flair==0.4.4

Getting the same error when trying to execute a python script.

(venv) ds@thinker:~/Documents/flair$ python flair.py 
Traceback (most recent call last):
  File "flair.py", line 2, in <module>
    from flair.data_fetcher import NLPTaskDataFetcher
  File "/home/ds/Documents/flair/flair.py", line 2, in <module>
    from flair.data_fetcher import NLPTaskDataFetcher
ModuleNotFoundError: No module named 'flair.data_fetcher'; 'flair' is not a package

Getting the same error when trying to execute a python script.

I found my file's name is flair.py.
Renaming helped me solve this problem.

ModuleNotFoundError: No module named 'flair'

The problem was that I named my python file "flair.py" just like @jinlukang1, renaming it solved the issue :)

Me too same problem "File name == 'flair.py' ", changing it fixes the issue. This issue should be closed I think @alanakbik ?

Was this page helpful?
0 / 5 - 0 ratings