Requests module not found on the rasa-sdk image

My Rasa X instance is connected with my git repo, everything works fine, except actions.

When my doesn’t contain the “import requests” line, my actions are running fine, but when I add import requests, there is a ModuleNotFound Exception. Apparently, the requests package is missing from the rasa image.

To resolve this, I tried building my own rasa image while adding the requests package like suggested in the docs: Deploying your Rasa Assistant.

This is my Dockerfile:

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:latest
# Add a custom python library (e.g. jupyter)
RUN pip --no-cache-dir install requests

This is the output:

Sending build context to Docker daemon  35.23MB
Step 1/2 : FROM rasa/rasa-sdk:latest
 ---> 1a54ed66135a
Step 2/2 : RUN pip --no-cache-dir install requests
 ---> Running in 980d6da2c146
Collecting requests
  Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
Requirement already satisfied: certifi>=2017.4.17 in /opt/venv/lib/python3.6/site-packages (from requests) (2019.11.28)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.8-py2.py3-none-any.whl (125 kB)
Requirement already satisfied: idna<3,>=2.5 in /opt/venv/lib/python3.6/site-packages (from requests) (2.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/venv/lib/python3.6/site-packages (from requests) (3.0.4)
Installing collected packages: urllib3, requests
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/venv/lib/python3.6/site-packages/urllib3'
Consider using the `--user` option or check the permissions.

The command '/bin/bash -o pipefail -c pip --no-cache-dir install requests' returned a non-zero code: 1
1 Like

Did you set up Rasa X with docker-compose? are you running docker commands as sudo?

Hi @falcononrails, sorry about this – the requests package is indeed missing, that should be fixed soon.

In the meantime, i think the issue is that although rasa-sdk uses root to install things, it uses user 1001 to run. Therefore the user running at the beginning doesn’t have the correct permissions. Try this:

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:latest
USER root
# Add a custom python library (e.g. jupyter)
RUN pip --no-cache-dir install requests
USER 1001

once the rasa/rasa-sdk:1.8.1 image comes out, you shouldn’t have to extend the image for the requests package.

1 Like

Thank you for your quick response. I solved the issue by using an older version of rasa-sdk. (v 1.7.0).