RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.91k stars 4.63k forks source link

Unhelpful message when spacy model isn't pre-downloaded #10232

Closed dakshvar22 closed 2 years ago

dakshvar22 commented 2 years ago

Rasa Open Source version

3.0.0rc2

Rasa SDK version

No response

Rasa X version

No response

Python version

3.8

What operating system are you using?

OSX

What happened?

Installed with pip install rasa[full]==3.0.0rc2 and tried training moodbot. Training fails with the end message being:

Traceback (most recent call last):
  File "/Users/daksh/miniconda3/envs/rasa-rc/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/__main__.py", line 121, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/cli/train.py", line 59, in <lambda>
    train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/cli/train.py", line 91, in run_training
    training_result = train_all(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/api.py", line 105, in train
    return train(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/model_training.py", line 170, in train
    return _train_graph(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/model_training.py", line 237, in _train_graph
    trainer.train(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/engine/training/graph_trainer.py", line 108, in train
    graph_runner.run(inputs={PLACEHOLDER_IMPORTER: importer})
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/engine/runner/dask.py", line 106, in run
    dask_result = dask.get(run_graph, run_targets)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 560, in get_sync
    return get_async(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 503, in get_async
    for key, res_info, failed in queue_get(queue).result():
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 545, in submit
    fut.set_result(fn(*args, **kwargs))
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 237, in batch_execute_tasks
    return [execute_task(*a) for a in it]
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 237, in <listcomp>
    return [execute_task(*a) for a in it]
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 228, in execute_task
    result = pack_exception(e, dumps)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/local.py", line 223, in execute_task
    result = _execute_task(task, data)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/dask/core.py", line 121, in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/engine/graph.py", line 442, in __call__
    self._load_component(**constructor_kwargs)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/engine/graph.py", line 399, in _load_component
    raise GraphComponentException(
rasa.engine.exceptions.GraphComponentException: Error initializing graph component for node 'provide_SpacyNLP0'.

The information that spacy model should be downloaded is hidden above the traceback:

2021-11-16 11:29:23 INFO     rasa.nlu.utils.spacy_utils  - Trying to load SpaCy model with name 'en_core_web_md'.
Traceback (most recent call last):
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py", line 93, in load_model
    language = spacy.load(spacy_model_name, disable=["parser"])
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/spacy/__init__.py", line 51, in load
    return util.load_model(
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/spacy/util.py", line 427, in load_model
    raise IOError(Errors.E050.format(name=name))
OSError: [E050] Can't find model 'en_core_web_md'. It doesn't seem to be a Python package or a valid path to a data directory.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/engine/graph.py", line 387, in _load_component
    self._component: GraphComponent = constructor(  # type: ignore[no-redef]
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py", line 121, in create
    model = cls.load_model(spacy_model_name)
  File "/Users/daksh/miniconda3/envs/rasa-rc/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py", line 96, in load_model
    raise InvalidModelError(
rasa.nlu.model.InvalidModelError: Please confirm that en_core_web_md is an available spaCy model. You need to download one upfront. For example:
python -m spacy download en_core_web_md
More informaton can be found on https://rasa.com/docs/rasa/components#spacynlp

In rasa==2.8.x, we used to detect this upfront and throw this error:

2021-11-16 11:46:07 INFO     rasa.nlu.utils.spacy_utils  - Trying to load spacy model with name 'en_core_web_md'
InvalidModelError: Please confirm that en_core_web_md is an available spaCy model. You need to download one upfront. For example:
python -m spacy download en_core_web_md
More informaton can be found on https://rasa.com/docs/rasa/components#spacynlp

Command / Request

rasa train

Relevant log output

No response

carlad commented 2 years ago

Steps to reproduce: From rasa home directory make install-full This gets the spacy library, which is needed, but not the spacy model (the condition you want to be in)

Once rasa is installed, go to the examples/moodbot folder of rasa and run rasa train. The error should then appear.

Alternatively, you can remove the spacy model with the following:

To again download the model, you can run python -m spacy download en_core_web_md