Action Server pandas-module not found

Hello,

i’m using a Rasa X Docker-Compose setup and want to use a custom action for the action_default_ask_affirmation action. I basically want to replace the phrase “Did you mean” for the Two Stage Fallback policy and use a intention mapping. I used the code from the rasa-demo repo: rasa-demo/actions.py at 3e2bbc7b2615a60a13fb750921bf985b68bc4d29 · RasaHQ/rasa-demo · GitHub

But i’m running into the following problem:

rasa_sdk.endpoint  - Starting action endpoint server...
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/rasa_sdk/__main__.py", line 34, in <module>
    main()
  File "/app/rasa_sdk/__main__.py", line 30, in main
    main_from_args(cmdline_args)
  File "/app/rasa_sdk/__main__.py", line 21, in main_from_args
    args.auto_reload,
  File "/app/rasa_sdk/endpoint.py", line 137, in run
    action_package_name, cors_origins=cors_origins, auto_reload=auto_reload
  File "/app/rasa_sdk/endpoint.py", line 80, in create_app
    executor.register_package(action_package_name)
  File "/app/rasa_sdk/executor.py", line 254, in register_package
    self._register_all_actions()
  File "/app/rasa_sdk/executor.py", line 271, in _register_all_actions
    self.register_action(action)
  File "/app/rasa_sdk/executor.py", line 165, in register_action
    action = action()
  File "/app/actions/actions.py", line 21, in __init__
    import pandas as pd
ModuleNotFoundError: No module named 'pandas' 

The action server can’t find the pandas module. Is there a way to solve this?

Hi Jan,

You need to build your own action server image and install pandas. The rasa-demo repo has an example Dockerfile that does this and the associated actions/requirements-actions.txt.

Your docker-compose then needs to use your image instead of the default action image.

Greg

Hi Greg,

thank you for your reply. I changed my Dockerfile closer to how it is in the rasa-demo repo and added the setup.py and actions/requirements-actions.txt. I also added a docker-compose.override.yml file with the following content:

version: '3.4'

services:
  app:
      image: rasa/rasa-sdk:latest
      volumes:
        - ./actions:/app/actions

How exactly do I go from here? Do I also have to change something in the docker-compose.yml? And if I’m building my action server image (via this) do I have to push it to somethin like DockerHub or is this not necessary if I only need this image on that server?

Jan

Jan,

The docker site has an example of building and using your own image here. You can also build and push the image to a docker repo which is what you would typically do in a production environment. There should be lots of docker examples out there on the ways you can do this for your setup.

Greg

In most cases this error in Python generally raised:

  • You haven’t installed Pandas explicitly with pip install pandas.
  • You may have different Python versions on your computer and Pandas is not installed for the particular version you’re using.

You can run the following command in your Linux/MacOS/Windows terminal.

pip install pandas

To be sure you are not having multiple Python versions that are confusing, you should run following commands:

python3 -m pip install pandas
python3 -c 'import pandas'