No module named 'actions.actions'

Hi, I’m running Rasa X on a server, and I’m getting this error:

app_1              | Traceback (most recent call last):
app_1              |   File "/app/rasa_sdk/executor.py", line 206, in register_package
app_1              |     self._import_submodules(package)
app_1              |   File "/app/rasa_sdk/executor.py", line 191, in _import_submodules
app_1              |     package = importlib.import_module(package)
app_1              |   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
app_1              |     return _bootstrap._gcd_import(name[level:], package, level)
app_1              |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
app_1              |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
app_1              |   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
app_1              | ModuleNotFoundError: No module named 'actions.actions'
app_1              | 2020-01-22 13:55:46 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
app_1              | 2020-01-22 13:55:46 ERROR    rasa_sdk.executor  - Failed to register package 'actions.actions'.
app_1              | Traceback (most recent call last):
app_1              |   File "/app/rasa_sdk/executor.py", line 206, in register_package
app_1              |     self._import_submodules(package)
app_1              |   File "/app/rasa_sdk/executor.py", line 191, in _import_submodules
app_1              |     package = importlib.import_module(package)
app_1              |   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
app_1              |     return _bootstrap._gcd_import(name[level:], package, level)
app_1              |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
app_1              |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
app_1              |   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
app_1              | ModuleNotFoundError: No module named 'actions.actions'

When looking for my app logs. What can it be?

Thank you, Tiziano

1 Like

Hello, Tiziano.

I’m also new to Rasa but will try to help you.

Did you run your action servers in another command prompt with the call “rasa run actions”?

Also, can you paste your actions file?

Hope to help you and good luck.

Hi Alan,

I’m not running Rasa in local, I’m running it on a server with Docker. My action server starts when I run the command docker-compose up.

Hey @tiziano not sure if you’ve resolved this since. But what does your Dockerfile for the app server look like? And your docker-compose entry?

Hi @akelad, nop still not solved.

Here is my Dockerfile:

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:latest

# Add a custom python library (e.g. jupyter)
RUN pip install --no-cache-dir pandas

COPY data/intent_description_mapping.csv data/

And the docker-compose:

version: "3.4"

x-database-credentials: &database-credentials
  DB_HOST: "db"
  DB_PORT: "5432"
  DB_USER: "${DB_USER:-admin}"
  DB_PASSWORD: "${DB_PASSWORD}"
  DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"

x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "user"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-redis-credentials: &redis-credentials
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  REDIS_PASSWORD: ${REDIS_PASSWORD}
  REDIS_DB: "1"

x-duckling-credentials: &duckling-credentials
  RASA_DUCKLING_HTTP_URL: "http://duckling:8000"

x-rasax-credentials: &rasax-credentials
  LOCAL_MODE: "false"
  RASA_X_HOST: "http://rasa-x:5002"
  RASA_X_TOKEN: ${RASA_X_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5055"
  RASA_PRODUCTION_HOST: "http://rasa-production:5005"
  RASA_WORKER_HOST: "http://rasa-worker:5005"
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_WORKER_TOKEN: ${RASA_TOKEN}

x-rasa-credentials: &rasa-credentials
  <<: *rabbitmq-credentials
  <<: *rasax-credentials
  <<: *database-credentials
  <<: *redis-credentials
  <<: *duckling-credentials
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_MODEL_PULL_INTERVAL: 10
  RABBITMQ_QUEUE: "rasa_production_events"

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --debug
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x
    - rabbit
    - redis

services:
  action_server:
    image: pandasimg:latest
    volumes:
      - ./actions:/app/actions
  rasa-x:
    restart: always
    image: "rasa/rasa-x:${RASA_X_VERSION}"
    expose:
      - "5002"
    volumes:
      - ./models:/app/models
      - ./environments.yml:/app/environments.yml
      - ./credentials.yml:/app/credentials.yml
      - ./endpoints.yml:/app/endpoints.yml
      - ./logs:/logs
      - ./auth:/app/auth
    environment:
      <<: *database-credentials
      <<: *rasa-credentials
      SELF_PORT: "5002"
      DB_DATABASE: "${DB_DATABASE:-rasa}"
      RASA_MODEL_DIR: "/app/models"
      PASSWORD_SALT: ${PASSWORD_SALT}
      RABBITMQ_QUEUE: "rasa_production_events"
      RASA_X_USER_ANALYTICS: "0"
      SANIC_RESPONSE_TIMEOUT: "3600"
      METRICS_CONSENT: "${METRICS_CONSENT:-false}"
      UUID: "${UUID:-''}"
    depends_on:
      - db

  rasa-production:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "production"
      DB_DATABASE: "tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  rasa-worker:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "worker"
      DB_DATABASE: "worker_tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  app:
    restart: always
    image: "rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
    expose:
      - "5055"
    depends_on:
      - rasa-production

  db:
    restart: always
    image: "bitnami/postgresql:11.3.0"
    expose:
      - "5432"
    environment:
      POSTGRESQL_USERNAME: "${DB_USER:-admin}"
      POSTGRESQL_PASSWORD: "${DB_PASSWORD}"
      POSTGRESQL_DATABASE: "${DB_DATABASE:-rasa}"
    volumes:
      - ./db:/bitnami/postgresql

  rabbit:
    restart: always
    image: "bitnami/rabbitmq:3.7.17"
    environment:
      RABBITMQ_HOST: "rabbit"
      RABBITMQ_USERNAME: "user"
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
      RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
    expose:
      - "5672"

  duckling:
    restart: always
    image: "rasa/duckling:latest"
    expose:
      - "8000"
    command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

  nginx:
    restart: always
    image: "rasa/nginx:${RASA_X_VERSION}"
    ports:
      - "80:8080"
      - "443:8443"
    volumes:
      - ./certs:/opt/bitnami/certs
      - ./terms:/opt/bitnami/nginx/conf/bitnami/terms
    depends_on:
      - rasa-x
      - rasa-production
      - app

  redis:
    restart: always
    image: "bitnami/redis:5.0.5"
    ports:
      - "6379:6379"
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD}

  logger:
    restart: always
    image: "rasa/logger:${RASA_X_VERSION}"
    command: ["/bin/sh", "-c", "docker-compose logs --no-color -f > /logs/compose_`date '+%Y-%m-%d_%H:%M:%S'`.log"]
    volumes:
      - ./logs:/logs
      - ./.env/:/etc/rasa/.env
      - ./docker-compose.yml:/etc/rasa/docker-compose.yml
      - /var/run/docker.sock:/var/run/docker.sock
    working_dir: /etc/rasa
    depends_on:
      - nginx
      - duckling

Ok and what does the directory structure look like for the actions folder that you mounted?

I have a folder actions inside /etc/rasa and the file actions.py inside the folder actions.

Hi Tiziano,

I’m debugging this same issue as well. Did you manage to fix it?

Nop, still there

Is in this actions folder a file called __init__.py?

Yes

image

Tiziano, try my Dockerfile:

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:latest

# Copy actions into container
COPY actions /app/actions/

# Copy data into container
COPY data /app/data/

# Add a custom system library
RUN apt-get update

# Install pandas
RUN pip install pandas

Basically, I realized docker-compose mounting actions isn’t enough.

@tiziano maybe we should jump on another call for this?

one suggestion would be to exec into the container with docker exec -it container_id /bin/bash and checking if the actions directory is properly mounted

@hknajjar0 mounting the directory should definitely be enough, i don’t think you need to additionally specify this in your Dockerfile

Just try add this to your Dockerfile

WORKDIR /app

In the very last line. I’ve got similar error, and it turned out to be that rasa command is being executed from a wrong working dir.