installing scikit-learn Docker image problem

Viewed 2216

im trying to install scikit-learn with docker image! its failed and here is the error:

ImportError: Numerical Python (NumPy) is not installed. scikit-learn requires NumPy >= 1.8.2. Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html Failed building wheel for scikit-learn

but in logs just before of scikit-learn pip trying to isntall numpy==1.9.0 and log says its DONE, I even try to install with :

scikit-learn[alldeps]==0.19.1

but nothing is changed! same error

my hole docker image is working well without scikit-learn, my app is running except the scikit-learn parts!

I tried to change the version and install the last version:

scikit-learn[alldeps]

and its ok but I have some incompatibility in my application I need to use the 0.19.1 version, not 0.19.2!

ps: my requirements.txt file is working in my python3 venv (mac and ubuntu)!!!

1 Answers

I know it's a bit late but faced a similar issue with heroku (they also use linux environments). What you have to do is check the version of your local/dev environment and use that specific versions while deploying, even the python version.

import scipy
import sklearn
import numpy

print(scipy.__version__)
print(sklearn.__version__)
print(numpy.__version__)

Add this versions specifically to requirements.txt

scipy==1.4.1
scikit-learn==0.22.2.post1
numpy==1.19.5

In heroku to set the Python runtime, add a runtime.txt file to your app’s root directory that declares the exact version number to use:

python-3.7.10
Related