Rasa: train-core: "python -m rasa_core.train -s data/stories.md -d domain.yml -o models/dialogue --epochs 300" It gives "ImportError: cannot import name Deque".

Created on 19 Jan 2018  路  8Comments  路  Source: RasaHQ/rasa

Rasa Core version: 0.8.0a4 | 0.8.0a4-py2.7.egg

Python version: 2.7.14 :: Anaconda custom (64-bit)

Operating system (windows, osx, ...): ubuntu 16.04

Issue: train-core
running command: sudo python -m rasa_core.train -s data/stories.md -d domain.yml -o models/dialogue --epochs 300
When I train-core using "sudo" it gives following error:-
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "build/bdist.linux-x86_64/egg/rasa_core/train.py", line 11, in
File "build/bdist.linux-x86_64/egg/rasa_core/agent.py", line 17, in
File "build/bdist.linux-x86_64/egg/rasa_core/policies/__init__.py", line 6, in
File "build/bdist.linux-x86_64/egg/rasa_core/policies/policy.py", line 19, in
File "build/bdist.linux-x86_64/egg/rasa_core/training/__init__.py", line 11, in
File "build/bdist.linux-x86_64/egg/rasa_core/training/dsl.py", line 20, in
File "build/bdist.linux-x86_64/egg/rasa_core/training/structures.py", line 13, in
ImportError: cannot import name Deque

And when I train-core without using "sudo" it gives following error:-

/home/username/anaconda2/bin/python: No module named rasa_core

Content of domain file:

intents:
  - greet
  - goodbye
  - mood_affirm
  - mood_deny
  - mood_great
  - mood_unhappy

templates:
  utter_greet:
  - text: "Hey! How are you?"
    buttons:
    - title: "great"
      payload: "great"
    - title: "super sad"
      payload: "super sad"

  utter_cheer_up:
  - text: "Here is something to cheer you up:"
    image: "https://cdn77.eatliver.com/wp-content/uploads/2017/10/trump-frog.jpg"

  utter_did_that_help:
  - text: "Did that help you?"

  utter_happy:
  - text: "Great carry on!"

  utter_goodbye:
  - text: "Bye"

actions:
  - utter_greet
  - utter_cheer_up
  - utter_did_that_help
  - utter_happy
  - utter_goodbye


thanks adv :)

Most helpful comment

New version is released as 0.8.1

All 8 comments

same here... I'm also facing the ImportError issue for typing package and Deque model.

tried to uninstall the following package and installed it with updated version still stuck at the same error. @tmbo

same here - pip list | grep typing gave me typing (3.5.3.0).

But unlike @venky14 uninstalling and installing the latest version didn't persist the problem.

pip uninstall typing && pip install typing lead to version 3.6.2 being installed.

To be added:

  • had the issue with rasa_core.run without using sudo
  • os: Ubuntu 14.04.5

Is it possible that is has something to do with permissions? - using sudo in combination with pip and mixing system python with the user one.
Facing this issue on a older server instance where things are a bit messed up. Locally I do have errors at all.

I am not sure where this is coming from. When running pip install rasa_core or pip install -e . in the source root and a clean environment I get typing==3.6.2. I mean there is a version bound on it in setup.py as well as a specific version set in requirements.txt.

I will make the change to use Pipfiles instead of requirements.txt soon anyway - might fix this setup issue as well.

This issue surfaced with the latest version of RASA (0.8.0a4). It, or one of its dependencies, relies on a Deque collection type in the typing module, which doesn't exist by default in Python 2.7 like it does in later versions--I want to say 3.5 and up. You can upgrade your Python, or you can install the wheel for your Python version. To install, download the correct wheel, and then in the directory, run pip install <filename>.

@tmbo
I am having the same issue with python 3.5.2, reproducible for moodbot:

[rasa_core/examples/moodbot]# python3 -m rasa_core.train -s data/stories.md -d domain.yml -o models/dialogue --epochs 300
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/train.py", line 12, in <module>
    from rasa_core.agent import Agent
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/agent.py", line 17, in <module>
    from rasa_core.policies import PolicyTrainer, Policy
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/policies/__init__.py", line 6, in <module>
    from rasa_core.policies.policy import Policy
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/policies/policy.py", line 19, in <module>
    from rasa_core.training.data import DialogueTrainingData
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/training/__init__.py", line 11, in <module>
    from rasa_core.training.dsl import StoryFileReader
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/training/dsl.py", line 20, in <module>
    from rasa_core.training.structures import (
  File "/usr/local/lib/python3.5/dist-packages/rasa_core/training/structures.py", line 13, in <module>
    from typing import List, Text, Dict, Optional, Tuple, Any, Deque, Set
ImportError: cannot import name 'Deque'

Installed packages:

absl-py (0.1.10)
alabaster (0.7.10)
APScheduler (3.5.1)
attrs (17.4.0)
Automat (0.6.0)
Babel (2.5.3)
behave (1.2.5)
bleach (2.1.2)
boto3 (1.5.22)
botocore (1.8.36)
certifi (2018.1.18)
chardet (3.0.4)
click (6.7)
cloudpickle (0.5.2)
coloredlogs (9.0)
ConfigArgParse (0.12.0)
constantly (15.1.0)
coverage (4.4.2)
cycler (0.10.0)
decorator (4.2.1)
docopt (0.6.2)
docutils (0.14)
entrypoints (0.2.3)
fakeredis (0.9.0)
fbmessenger (5.0.0)
Flask (0.12.2)
Flask-Cors (3.0.3)
freezegun (0.3.9)
future (0.16.0)
futures (3.1.1)
gevent (1.2.2)
graphviz (0.8.2)
greenlet (0.4.12)
h5py (2.7.1)
html5lib (0.9999999)
humanfriendly (4.8)
hyperlink (17.3.1)
idna (2.6)
imagesize (0.7.1)
incremental (17.5.0)
ipython-genutils (0.2.0)
itsdangerous (0.24)
Jinja2 (2.10)
jmespath (0.9.3)
jsonpickle (0.9.5)
jsonschema (2.6.0)
jupyter-core (4.4.0)
Keras (2.1.3)
klein (17.10.0)
Markdown (2.6.11)
MarkupSafe (1.0)
matplotlib (2.1.2)
mistune (0.8.3)
motor (1.2.1)
multidict (4.0.0)
nbconvert (5.3.1)
nbformat (4.4.0)
nbsphinx (0.3.1)
networkx (2.1)
numpy (1.14.0)
pandas (0.22.0)
pandoc (1.0.2)
pandocfilters (1.4.2)
parse (1.8.2)
parse-type (0.4.2)
pathlib (1.0.1)
pip (9.0.1)
ply (3.10)
protobuf (3.5.1)
pulsar (2.0.2)
Pygments (2.2.0)
pykwalify (1.6.0)
pymongo (3.6.0)
pyparsing (2.2.0)
python-dateutil (2.6.1)
python-telegram-bot (9.0.0)
pytz (2017.3)
PyYAML (3.12)
rasa-core (0.8.0)
rasa-nlu (0.11.0)
redis (2.10.6)
requests (2.18.4)
ruamel.yaml (0.15.35)
s3transfer (0.1.12)
scikit-learn (0.19.1)
scipy (1.0.0)
setuptools (20.7.0)
simplejson (3.13.2)
six (1.11.0)
slackclient (1.1.1)
snowballstemmer (1.2.1)
Sphinx (1.6.6)
sphinxcontrib-websupport (1.0.1)
tensorflow (1.5.0)
tensorflow-tensorboard (1.5.0)
testfixtures (5.4.0)
testpath (0.3.1)
tqdm (4.19.5)
traitlets (4.3.2)
transitions (0.6.4)
Twisted (17.9.0)
typing (3.6.4)
tzlocal (1.5.1)
urllib3 (1.22)
websocket-client (0.46.0)
Werkzeug (0.14.1)
wheel (0.29.0)
ZConfig (3.2.0)
zdaemon (4.2.0)
zope.interface (4.4.3)

Remove 'Deque' from /usr/local/lib/python3.5/dist-packages/rasa_core/training/structures.py

Ok should be fine now. deque doesn't exist in python 3.5. It is removed now and python 3.5 is added to the travis test.

New version is released as 0.8.1

Was this page helpful?
0 / 5 - 0 ratings