I'm exploring Python through building its Docker image. I want to use the scipy
library but I'm not able to import it for some reason. Here are the imports for my __init.py__
file:
import numpy as np
import scipy.stats as sp
from flask import Flask, g
from flask_restful import Resource, Api, reqparse
My Dockerfile
:
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./run.py" ]
requirements.txt
:
numpy==1.19.0
scipy==0.15.1
Flask==0.12.2
markdown==2.6.11
flask-restful==0.3.6
And finally my docker-compose.yml
:
version: '3.4'
services:
calculator:
build: .
volumes:
- .:/usr/src/app
ports:
- 5000:80
Now when I do a docker-compose up
this is the error:
calculator | Traceback (most recent call last):
calculator | File "./run.py", line 1, in <module>
calculator | from probability_calculator import app
calculator | File "/usr/src/app/probability_calculator/__init__.py", line 2, in <module>
calculator | import scipy.stats as sp
calculator | ModuleNotFoundError: No module named 'scipy'
I've had a look here but adding those lines to the Dockerfile
still doesn't seem to work.