Getting error while starting the action server after upgrading rasa to latest version

Hey guys I just upgraded my rasa from 1.12 to 1.9.6. Earlier it was all good but after upgrading I’m getting this error while running the action server

Traceback (most recent call last):
  File "C:\Users\91973\Anaconda3\envs\chatbot\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\91973\Anaconda3\envs\chatbot\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\91973\Anaconda3\envs\chatbot\lib\site-packages\rasa_core_sdk\endpoint.py", line 14, in <module>
    from rasa_core_sdk.executor import ActionExecutor
  File "C:\Users\91973\Anaconda3\envs\chatbot\lib\site-packages\rasa_core_sdk\executor.py", line 14, in <module>
    from rasa_core_sdk import utils, Action, Tracker
ImportError: cannot import name 'Action'

Please help, I need to finish this project ASAP

show your action.py file

@bparikh99 Here it is

from typing import Any, Text, Dict, List
from rasa_core_sdk import Action
from rasa_core_sdk import Tracker
from rasa_core_sdk.events import SlotSet
from rasa_sdk.executor import CollectingDispatcher


class MedicalNecessity(Action):
    def name(self) -> Text:
        return "action_necessity"

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

        # from database medical necessity reason is fetched and stored in 'reason' variable
        reason = 'xyz'

        bot_response = " For {} incident number the medical necessity reason is {}".format(incident_no, reason)

        dispatcher.utter_message(text=bot_response)
        return [SlotSet('incident_no', incident_no)]


class ServiceLevel(Action):

    def name(self) -> Text:
        return "action_service"

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

        # from database service level is fetched and stored in 'level' variable
        level = 123

        bot_response = " For {} incident number the level of service is {}".format(incident_no, level)

        dispatcher.utter_message(text=bot_response)
        return [SlotSet('incident_no', incident_no)]


class NecessityAndService(Action):

    def name(self) -> Text:
        return "action_necessity_service"

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

        # from database medical necessity reason is fetched and stored in 'reason' variable
        # service level is fetched and stored in 'level' variable

        reason = 'abc'
        level = 123

        bot_response = " For {} incident number the medical necessity reason is {} and level of service is {}".format(
            incident_no, reason, level)

        dispatcher.utter_message(text=bot_response)
        return [SlotSet('incident_no', incident_no)]

@bparikh99 it was working perfectly in previous version

try using from rasa_sdk import Action, Tracker

also show versions of rasa-sdk ,

@Aman10 Add the below code into your actions.py

from typing import Dict, Text, Any, List, Union, Optional

from rasa_sdk import Tracker

from rasa_sdk.executor import CollectingDispatcher

from rasa_sdk import Action

from rasa_sdk.events import (SlotSet,AllSlotsReset)

I tried that but getting the same error

@bparikh99 I tried that too, still the error is there

Thanks guys @bparikh99 , @vishnunahak231 for the assist I found the prob

the rasa_core_sdk package is renamed to rasa_sdk, I was running the action server by this

python -m rasa_core_sdk.endpoint --actions actions.

For new version we should run action server by python -m rasa_sdk.endpoint --actions actions

1 Like