I installed the allennlp package by using pip install allennlp
. But when I tried to import it from Jupyter Notebook using this command from allennlp.commands.elmo import ElmoEmbedder
, it gave me an error ModuleNotFoundError: No module named 'allennlp.commands.elmo'
. I am wondering how should I fix this, I have the Python 3.7 installed and Spacy installed as well but for some reasons, I just cannot import the ElmoEmbedder
Asked
Active
Viewed 5,912 times
2

CodingStark
- 199
- 3
- 17
-
it sounds like you have multiple python interpreters installed. Are you sure that you installed the packages to the correct interpreter? – griffin_cosgrove Jul 14 '20 at 14:10
-
Yes, I am sure about it. – CodingStark Jul 15 '20 at 04:52
1 Answers
4
The current version of allennlp (1.0.0) does not contain the elmo.py file. Install it using
pip install allennlp==0.4.2
This will install version 0.4.2 which contains ElmoEmbedder. Installing this version of allennlp requires older versions of a lot of python packages (for example, torch 0.3.1 is needed), so i'd recommend installing it in a virtual environment.

arnavp
- 41
- 2
-
-
Installing this version of allennlp should automatically install torch 0.3.1. In case it doesn't, then you could do it manually – arnavp Jul 18 '20 at 19:56
-
I tried to install `pip install torch==0.3.1` before `pip install allennlp==0.4.2` but it gave me an error that they could not find torch 0.3.1 version. `ERROR: Could not find a version that satisfies the requirement torch==0.3.1 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.1.0.post2, 1.2.0, 1.3.0, 1.3.0.post2, 1.3.1, 1.4.0, 1.5.0, 1.5.1) ERROR: No matching distribution found for torch==0.3.1` – CodingStark Jul 19 '20 at 06:30
-
From what I have checked, I could'nt find a torch 0.3.1 distribution for windows. If you're running linux, you can go through the pytorch documentation and search for the matching distribution and install it manually. Otherwise, in my case it worked when I ran it in google colab. – arnavp Jul 20 '20 at 12:52