# RASA action server failing ModuleNotFoundError: No module named 'myfunc'

**URL:** <https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253>\
**Category:** Rasa Open Source\
**Created:** [December 23, 2021, 2:35pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253 "2021-12-23T14:35:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)\
**Post date:** [December 23, 2021, 2:35pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/1 "2021-12-23T14:35:53Z")

</div>

Hi Team, I am very new to Python & RASA.

I am trying to run rasa run actions but receiving errors: ModuleNotFoundError: No module named ‘myfunc’

Background: I have created a new py file as myfunc.py with a simple program to return string. I have imported myfunc.py in actions.py but when I trigger the action server it fails with the error ModuleNotFoundError: No module named ‘myfunc’.

Actions.PY code:

```auto
from myfunc import *
from typing import Any, Text, Dict, List
#
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

a = my_function()

class ActionHelloWorld(Action):

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

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

        dispatcher.utter_message(a)

        return []

```

Location:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/7/f/7f2e28f688b57c59d927fbb16818ba27764b30fe.png)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/7/2/723bd96ba7363afc7a788561b8449b34d0b70150.png)

Can someone help me to identify my mistake?

Regards, Mayank Pande

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 23, 2021, 3:14pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/2 "2021-12-23T15:14:13Z")

</div>

> [@mayank2288](#):
>
> `from myfunc import *`

Welcome Mayank @mayank2288 it should be

`from myfunc import <function name>`

can you even add the myfunc.py file OR check this [Python - Call function from another file - GeeksforGeeks](https://www.geeksforgeeks.org/python-call-function-from-another-file/)

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [December 23, 2021, 3:16pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/3 "2021-12-23T15:16:46Z")

</div>

Welcome to the forum 🙂

> [@mayank2288](#):
>
> `from myfunc import *`

Try `from . import myfunc` or `from .myfunc import my_function`

---

<div class="post-metadata">

**Author:** ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)\
**Post date:** [December 26, 2021, 3:14pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/4 "2021-12-26T15:14:09Z")

</div>

Hi All, Thank you for response. It worked, but I changed myfunc.py path to the main folder. All code is the same.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/b/8/b87f337ab9ed437c960e887a08c4a63b19b4637a.png)

Do we need to keep all py files under the root folder?

Regards, Mayank Pande

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [December 26, 2021, 4:49pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/5 "2021-12-26T16:49:54Z")

</div>

Which one worked? And do you have ` __init__.py` in your `actions` folder?

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 26, 2021, 6:10pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/6 "2021-12-26T18:10:37Z")

</div>

@mayank2288 That’s quite strange whilst moving file outside from the actions folder which have action.py and ` __init__.py` working fine with you. Normally all related files should be in the actions project folder in which the file is called.

---

<div class="post-metadata">

**Author:** ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)\
**Post date:** [December 27, 2021, 10:58am UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/7 "2021-12-27T10:58:07Z")

</div>

Hi Chris, Yes, I have ` __init__.py` in the actions folder. It was created with the` rasa init` command.

Regards, Mayank Pande

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [December 27, 2021, 11:21am UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/8 "2021-12-27T11:21:03Z")

</div>

> [@ChrisRahme](#):
>
> Which one worked?

Please answer this as well so we can help you

---

<div class="post-metadata">

**Author:** ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)\
**Post date:** [December 27, 2021, 1:11pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/9 "2021-12-27T13:11:23Z")

</div>

HI Chris, I moved `myfunc.py` file under main folder. i.e D:/Chat Bot. This is only change I did.

Regards, Mayank Pande

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 27, 2021, 2:16pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/10 "2021-12-27T14:16:34Z")

</div>

@mayank2288 Can you close this thread as solution for yourself and for others?

---

<div class="post-metadata">

**Author:** ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)\
**Post date:** [December 27, 2021, 3:33pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/11 "2021-12-27T15:33:43Z")

</div>

Hi Nik202.

Thank you . Yes, I can close the topic. But just to check, if I am doing things correctly? Is it the correct rasa way to call other py files from actions?

Regards. Mayank Pande

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [December 27, 2021, 3:38pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/12 "2021-12-27T15:38:52Z")

</div>

If you’re satisfied with the result then good enough.

But I suggest keeping all in the `action` folder using a method provided by Nik or me - whichever works 🙂

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 27, 2021, 4:23pm UTC](https://forum.rasa.com/t/rasa-action-server-failing-modulenotfounderror-no-module-named-myfunc/50253/13 "2021-12-27T16:23:57Z")

</div>

@mayank2288 for me and honest answer is “No” as a developer we normally put all the files in the actions.py folder (calling functions) its safe and easy to find and maintained. But as Chris says if this give your result and satisfied your use case or project its good to go. Good Luck!

Ref: [https://github.com/RasaHQ/rasa-demo/tree/main/actions](https://github.com/RasaHQ/rasa-demo/tree/main/actions) | [https://github.com/RasaHQ/financial-demo/tree/main/actions](https://github.com/RasaHQ/financial-demo/tree/main/actions)
