ModuleNotFoundError: No module named 'actions'

(base) C:\Users\admin>activate installingrasa

(installingrasa) C:\Users\admin>rasa run actions
2021-12-30 10:02:57 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2021-12-30 10:02:57 ERROR    rasa_sdk.executor  - Failed to register package 'actions'.
Traceback (most recent call last):
  File "e:\anaconda3\envs\installingrasa\lib\site-packages\rasa_sdk\executor.py", line 262, in register_package
    self._import_submodules(package)
  File "e:\anaconda3\envs\installingrasa\lib\site-packages\rasa_sdk\executor.py", line 218, in _import_submodules
    package = self._import_module(package)
  File "e:\anaconda3\envs\installingrasa\lib\site-packages\rasa_sdk\executor.py", line 239, in _import_module
    module = importlib.import_module(name)
  File "e:\anaconda3\envs\installingrasa\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'actions'

my blog: https://blog.csdn.net/duan_zhihua

Please share the output of rasa --version

1 Like
(installingrasa) C:\Users\admin>rasa --version
Rasa Version      :         3.0.4
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
Rasa X Version    :         None
Python Version    :         3.8.8
Operating System  :         Windows-10-10.0.18362-SP0
Python Path       :         e:\anaconda3\envs\installingrasa\python.exe

Do you have the __init__.py and action.py files in your actions folder?

1 Like

Include init.py and action.py files in the actions directory

Did you modify anything in the knowledge_base folder?

Can I please get more details on your case? Since you have many files it means it’s not the first time you use actions, so you did something to break it

1 Like

It seems you doesn’t run the command in the correct path “C:\Users\admin”. You should run this command in the path which contains a namespace package directory names “actions”

2 Likes

Hello and Welcome @diorw can you share the actions.py file, can be an issue of import actions. OR is that you install the rasa init in the project directory and first run rasa shell --debug to check bot is working or not? and we use rasa actions when we have custom code written in actions.py files. I’d recommend to see some videos on rasa, let me share you the one which will help you Conversational AI with Rasa: Introduction to Rasa - YouTube please do check the doc also for the code reference for 2.x and 3.x. Good Luck!

1 Like

What @diorw said is correct. Good catch, I didn’t notice the directories.

You should run the command in your chatbot’s root directory (the one where you did rasa init), and that directory should have an actions folder.

Again, please give us more detail about what you did. You may even need to reinstall Rasa if you messed up the source files.

2 Likes

Thank you very much for your guidance! I’ve just started learning rasa. I’m very honored to get your help. Now I re-enter the directory where actions is located. The command(rasa run actions) runs successfully and the operation( rasa shell --debug )runs successfully. It’s great!

(installingrasa) E:\starspace\my_rasa>rasa run actions
2021-12-31 09:25:16 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2021-12-31 09:25:16 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055
(installingrasa) E:\starspace\my_rasa>rasa shell --debug
......
2021-12-31 09:30:53 DEBUG    rasa.engine.graph  - Node 'run_DIETClassifier5' loading 'DIETClassifier.load' and kwargs: '{}'.
2021-12-31 09:30:53 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_DIETClassifier5' was requested for reading.
2021-12-31 09:30:53 DEBUG    rasa.utils.tensorflow.models  - Loading the model from C:\Users\admin\AppData\Local\Temp\tmpc1dq2w8c\train_DIETClassifier5\DIETClassifier.tf_model with finetune_mode=False...
2021-12-31 09:30:53 DEBUG    rasa.nlu.classifiers.diet_classifier  - You specified 'DIET' to train entities, but no entities are present in the training data. Skipping training of entities.
2021-12-31 09:30:53 DEBUG    rasa.nlu.classifiers.diet_classifier  - Following metrics will be logged during training:
2021-12-31 09:30:53 DEBUG    rasa.nlu.classifiers.diet_classifier  -   t_loss (total loss)
2021-12-31 09:30:53 DEBUG    rasa.nlu.classifiers.diet_classifier  -   i_acc (intent acc)
2021-12-31 09:30:53 DEBUG    rasa.nlu.classifiers.diet_classifier  -   i_loss (intent loss)
2021-12-31 09:31:02 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
........
2021-12-31 09:31:12 DEBUG    rasa.engine.graph  - Node 'run_TEDPolicy3' loading 'TEDPolicy.load' and kwargs: '{}'.
2021-12-31 09:31:12 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_TEDPolicy3' was requested for reading.
2021-12-31 09:31:12 DEBUG    rasa.utils.tensorflow.models  - Loading the model from C:\Users\admin\AppData\Local\Temp\tmpc1dq2w8c\train_TEDPolicy3\ted_policy.tf_model with finetune_mode=False...
2021-12-31 09:31:24 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
.......
1 Like

Awesome, glad to be of help :slight_smile:

Don’t hesitate to ask if you have any problems. I suggest you to take a look a the official Conversational AI with Rasa Open Source 3.x playlist.

And happy new year! :partying_face:

1 Like

Thank you for sharing this information and happy New Year! :sunny:

1 Like