nitishgupta/nmn-drop

ImportError: cannot import name 'TokenType

BabyCodr opened this issue · 1 comments

I've installed everything exactly as requested however I still get the following error

from allennlp.data.token_indexers.token_indexer import TokenIndexer, TokenType
ImportError: cannot import name 'TokenType' from 'allennlp.data.token_indexers.token_indexer' (/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp/data/token_indexers/token_indexer.py)

Full error is


Traceback (most recent call last):
File "/home/mvictor96/miniconda3/envs/myenv/bin/allennlp", line 8, in
sys.exit(run())
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp/main.py", line 19, in run
main(prog="allennlp")
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp/commands/init.py", line 91, in main
import_module_and_submodules(package_name)
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp/common/util.py", line 340, in import_module_and_submodules
module = importlib.import_module(package_name)
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/mnt/c/Users/matth/Documents/RedMan/src/nmn-drop/semqa/init.py", line 1, in
import semqa.state_machines
File "/mnt/c/Users/matth/Documents/RedMan/src/nmn-drop/semqa/state_machines/init.py", line 1, in
from semqa.state_machines.constrained_beam_search import FirstStepConstrainedBeamSearch
File "/mnt/c/Users/matth/Documents/RedMan/src/nmn-drop/semqa/state_machines/constrained_beam_search.py", line 6, in
from allennlp_semparse.state_machines.states import State
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/state_machines/init.py", line 26, in
from allennlp_semparse.state_machines.beam_search import BeamSearch
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/state_machines/beam_search.py", line 9, in
from allennlp_semparse.state_machines.states import State
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/state_machines/states/init.py", line 14, in
from allennlp_semparse.state_machines.states.coverage_state import CoverageState
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/state_machines/states/coverage_state.py", line 7, in
from allennlp_semparse.fields.production_rule_field import ProductionRule
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/fields/init.py", line 1, in
from allennlp_semparse.fields.knowledge_graph_field import KnowledgeGraphField
File "/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp_semparse/fields/knowledge_graph_field.py", line 14, in
from allennlp.data.token_indexers.token_indexer import TokenIndexer, TokenType
ImportError: cannot import name 'TokenType' from 'allennlp.data.token_indexers.token_indexer' (/home/mvictor96/miniconda3/envs/myenv/lib/python3.7/site-packages/allennlp/data/token_indexers/token_indexer.py)

Think this was due to using allennlp 1.0.0