Allennlp: No module named 'allennlp.modules.elmo'

Created on 14 Jun 2018  Â·  7Comments  Â·  Source: allenai/allennlp

I'm trying to use Elmo in my custom models, however I'm facing problems with importing it. Following the installation(pip install allennlp), I get the following error in iPython(Python 3.5.5):

In [2]: from allennlp.modules.elmo import Elmo, batch_to_ids
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-c7dc745f0b65> in <module>()
----> 1 from allennlp.modules.elmo import Elmo, batch_to_ids

ImportError: No module named 'allennlp.modules.elmo'

Sure enough when I check the installation directory(in my Anaconda environment), there is no sign of the elmo.py file and many other files(compared to the github directory). Do I need to install from source?

Most helpful comment

Also the same error on version python3.6,allennlp 1.0.0 ……

All 7 comments

What version do you have? Try upgrading.

Allennlp uses python 3.6 —- error seems unrelated, but figured I’d mention since you mention you’re on 3.5

Wow I didn't think that would be the problem but yeah it requires 3.6

I met this problem. My python version is 3.6.6, and I have installed allennlp(pip install allennlp), but it also came out the same mistakes. Can anybody help?

Traceback (most recent call last):
File "train.py", line 10, in
from models.newmodel import model
File "/home/desmon/GraphWriter/models/newmodel.py", line 4, in
from models.list_encoder import list_encode, lseq_encode
File "/home/desmon/GraphWriter/models/list_encoder.py", line 6, in
from allennlp.modules.elmo import Elmo
ModuleNotFoundError: No module named 'allennlp'

This error is almost certainly because your pip install allennlp command failed. Can you look at the logs from when you ran the pip install and double check that it succeeded?

Also the same error on version python3.6,allennlp 1.0.0 ……

ModuleNotFoundError: No module named 'allennlp.commands.elmo'
same error on python 3.6 and allennlp==1.0.0
Any help is appreciated.

Was this page helpful?
0 / 5 - 0 ratings