question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

custom components cannot be found

See original GitHub issue

Rasa version: rasa 1.0.1 Python version: Python 3.6.8 Operating system (windows, osx, …): Windows 10 Issue: custom components cannot be found.

Content of configuration file (config.yml):

# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: "zh"
pipeline:
  # - name: "whitespace_tokenizer.WhitespaceTokenizer"
  - name: "components.ChatTokenizer"
  - name: "CRFEntityExtractor"
  - name: "EntitySynonymMapper"
  - name: "CountVectorsFeaturizer"
  - name: "EmbeddingIntentClassifier"

I build a custom component, that is the files in my folder:

__init__.py   components.py    domain.yml     readme.md
__pycache__/  config.yml       endpoints.yml  test.py
actions.py    credentials.yml  logs/          tokens.py
api.py        data/            models/        whitespace_tokenizer.py

my component is components.ChatTokenizer, but I get this error:

(rasa) D:\OneDrive\05Work\rasabot>rasa train nlu --config config.yml --out models/ --nlu data/nlu.md --fixed-model-name nlu --debug
2019-05-22 18:40:22 DEBUG    rasa.skill  - Selected skills: [].
Training NLU model...
Traceback (most recent call last):
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\registry.py", line 141, in get_component_class
    return utils.class_from_module_path(component_name)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\utils\__init__.py", line 140, in class_from_module_path
    m = importlib.import_module(module_name)
  File "d:\programs\miniconda3\envs\rasa\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'components'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\programs\miniconda3\envs\rasa\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\programs\miniconda3\envs\rasa\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Programs\Miniconda3\envs\rasa\Scripts\rasa.exe\__main__.py", line 9, in <module>
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\__main__.py", line 70, in main
    cmdline_arguments.func(cmdline_arguments)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\cli\train.py", line 132, in train_nlu
    fixed_model_name=args.fixed_model_name,
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\train.py", line 373, in train_nlu
    fixed_model_name=fixed_model_name,
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\train.py", line 392, in _train_nlu_with_validated_data
    config, nlu_data_directory, _train_path, fixed_model_name="nlu"
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\train.py", line 83, in train
    trainer = Trainer(nlu_config, component_builder)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\model.py", line 148, in __init__
    components.validate_requirements(cfg.component_names)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\components.py", line 36, in validate_requirements
    component_class = registry.get_component_class(component_name)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\registry.py", line 150, in get_component_class
    "in a module.".format(component_name)
Exception: Failed to find component class for 'components.ChatTokenizer'. Unknown component name. Check your configured pipeline and make sure the mentioned component is not misspelled. If you are creating your own component, make sure it is either listed as part of the `component_classes` in `rasa.nlu.registry.py` or is a proper name of a class in a module.

but I try to copy whitespace_tokenizer.py as my custom component, and use :

- name: "whitespace_tokenizer.WhitespaceTokenizer"

I get the same error:

(rasa) D:\OneDrive\05Work\rasabot>rasa train nlu --config config.yml --out models/ --nlu data/nlu.md --fixed-model-name nlu --debug
2019-05-22 18:43:53 DEBUG    rasa.skill  - Selected skills: [].
Training NLU model...
Traceback (most recent call last):
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\registry.py", line 141, in get_component_class
    return utils.class_from_module_path(component_name)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\utils\__init__.py", line 140, in class_from_module_path
    m = importlib.import_module(module_name)
  File "d:\programs\miniconda3\envs\rasa\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'whitespace_tokenizer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\programs\miniconda3\envs\rasa\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\programs\miniconda3\envs\rasa\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Programs\Miniconda3\envs\rasa\Scripts\rasa.exe\__main__.py", line 9, in <module>
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\__main__.py", line 70, in main
    cmdline_arguments.func(cmdline_arguments)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\cli\train.py", line 132, in train_nlu
    fixed_model_name=args.fixed_model_name,
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\train.py", line 373, in train_nlu
    fixed_model_name=fixed_model_name,
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\train.py", line 392, in _train_nlu_with_validated_data
    config, nlu_data_directory, _train_path, fixed_model_name="nlu"
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\train.py", line 83, in train
    trainer = Trainer(nlu_config, component_builder)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\model.py", line 148, in __init__
    components.validate_requirements(cfg.component_names)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\components.py", line 36, in validate_requirements
    component_class = registry.get_component_class(component_name)
  File "d:\programs\miniconda3\envs\rasa\lib\site-packages\rasa\nlu\registry.py", line 150, in get_component_class
    "in a module.".format(component_name)
Exception: Failed to find component class for 'whitespace_tokenizer.WhitespaceTokenizer'. Unknown component name. Check your configured pipeline and make sure the mentioned component is not misspelled. If you are creating your own component, make sure it is either listed as part of the `component_classes` in `rasa.nlu.registry.py` or is a proper name of a class in a module.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
XiaofeiQiancommented, May 27, 2019

@wochinge 👍 YES, THANKS! You are right, that is what I was missing!

But I use conda environment for rasa, my component use some relative path, so it is not good to use an extra directory. It is complex to add python search path for conda evns, I have try times, I can import cumtom component in rasa env by import code, but raise error by run rasa train, allways get the same error like can not find component.

Now I use python -m rasa train, it works fine.

I will close this issue, but still think if we can build custom component, maybe we need more friendly way to use it.

Thank again!

0reactions
XiaofeiQiancommented, May 28, 2019

@wochinge I used the solution for the conda environment you provided, and it works very well now, thank you very much.👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom components not found in integrations
I have a couplpe of custom components that I want to use (Ginlong Solis PV portal integration and Waste Collection Schedule) that are...
Read more >
[NOOB] Custom Component not found : r/homeassistant
You just go to the main integrations page and your new component should be in the list of components you can add. You...
Read more >
Troubleshooting Custom Components (C++) - RAD Studio
The most common causes for components not appearing in the list or on the palette: Missing PACKAGE modifier on the Register function; Missing...
Read more >
Cannot import my custom components in Angular
After reviewing your repository, I found out that your issue is that you've not imported the BaseModule inside your AppModule .
Read more >
Custom Components Missing - Cocos Creator
You need to add some script in your project. It looks like your script has compile error, please check. JeremiahTDK ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found