skip to Main Content

I have created the docker image to run python script. Now when I run below command it throwing error.
command in powershell:
docker build -t pull_request_summary .

Error:
Traceback (most recent call last):
File "/usr/app/src/./listPullRequest.py", line 1, in
import requests
ModuleNotFoundError: No module named ‘requests’

Just to confirm the "requests module is already installed on my machine. The script is running fine if I directly run from PowerShell. It just throwing error while running docker images.
My question is where it is expecting the "request" module of python?

2

Answers


  1. your container also must have requests installed on it
    In your docker file put this line

    RUN pip install requests
    
    Login or Signup to reply.
  2. I had this same error even when including RUN pip install requests in the Dockerfile. My solution was to change from:

    CMD ./myscript.py
    

    to:

    CMD [ "python", "./myscript.py" ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search