Error when running custom action: "ModuleNotFoundError: No module named 'rasa_sdk'"

I have everything installed. I can run the shell perfectly. Now I wanted to start writing some code in custom actions, but the module does not get imported. How do I fix this? I am using visual studio code.

@mx06148391 Hello and Welcome to the forum!

Can you please share rasa --version?

Hello. Before I do that let me tell you something that migh be relevant. I had an old laptop with rasa 2.8 and I had to get rid of it so I uploaded all the rasa files to my drive, and when I got another laptop I installed rasa 3.0 and then replaced the new files with my old ones. Could this be the problem? anyway here is the version: Rasa Version : 3.0.5 Minimum Compatible Version: 3.0.0 Rasa SDK Version : 3.0.4 Rasa X Version : None Python Version : 3.8.10

@mx06148391 Thanks a lot for the extra information, yes it help me to provide you exact solution.

Can you please update this in your actions.py

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

If it already exists, please share the error screenshot.

Or please share the actions.py.

@mx06148391 can you install pip install pytest in your working environment?

@mx06148391 Can you please share and see PROBLEMS in VS terminal, it’s showing 2 issues?

pytest is already installed. image

@mx06148391 Ok, did you create any custom actions, and when you run rasa run actions you see this error. please share your actions.py with me.

from typing import Any, Text, Dict, List
#
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
#
#
class ActionHelloWorld(Action):
#
    def name(self) -> Text:
        return "action_hello_world"

    def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        dispatcher.utter_message(text="Hello World!")

        return []

I didnt write any code yet. I just removed the comments to start using it, but I want the module to import first

also rasa run actions works fine.

@mx06148391 it’s running fine?

you getting this:-

2022-01-28 21:32:56 INFO rasa_sdk.endpoint - Action endpoint is up and running on http://0.0.0.0:5055

Yes or No?

@mx06148391 and you seeing 2 issues in Problems right?

yes. the server starts fine. but the code cant run because the module is not imported.

@mx06148391 strange, let me see this in detail give me some time, please.

@mx06148391 can you check your Python Interpreter (CLT+SHIFT+P) what is the python version selected it should be 3.7 or 3.8. Just confirming.

its 3.8

@mx06148391 I’m seeing your issue only give me some time, please.

@mx06148391 how do you create the environment? its conda or venv only?

I used venv only

@mx06148391 this error is very strange. I am still not able to crack it will be a very stupid issue but I’m trying.

@mx06148391 It can be major major bug also.

Should I try to uninstall everything and start all over using conda?

@mx06148391 Yes, I was about to write this and make sure please solve all conflicts.

Do check the rasa --version when you install.

Please try to install anaconda, create a conda environment and install rasa 3.x

Meanwhile, I am seeing this issue

OR

@mx06148391 Even you can create fresh venv, please.

Always mention me @ nik202 please.