missing numpy header while installing sklearn on alpine linux

  • Last Update :
  • Techknowledgy :

I suggest you to install py-numpy-dev in your Dockerfile:

 RUN apk add py - numpy - dev

Suggestion : 2

Better use following: RUN pip install --no-cache-dir numpy scipy pandas matplotlib,I assume you can add matplotlib and pandas as extra packages without problems. See https://pythonspeed.com/articles/alpine-docker-python/ for my choice to start from python:slim.,I had the same problem as you and found that pandas is still trying to install most recent version of numpy even if you already satisfied its requirement of numpy > 1.9 so I resolved it by:,EDIT: you might also need to install py-numpy-dev to get Numpy C headers required by other Python compiled libraries.

Is this still working? I'm getting:

ERROR: unsatisfiable constraints:
   so: libgfortran.so .5(missing):
   required by: openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5] openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5] openblas - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]

I'm getting

fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
   fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
   fetch http: //dl-8.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
   ERROR: unsatisfiable constraints:
   so: libgfortran.so .5(missing):
   required by:
   openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
The command '/bin/sh -c apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev'
returned a non - zero code: 4

I'm getting

fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
   fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
   fetch http: //dl-8.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
   ERROR: unsatisfiable constraints:
   so: libgfortran.so .5(missing):
   required by:
   openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
The command '/bin/sh -c apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev'
returned a non - zero code: 4

I'm getting

fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
   fetch http: //dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
   fetch http: //dl-8.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
   ERROR: unsatisfiable constraints:
   so: libgfortran.so .5(missing):
   required by:
   openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - ilp64 - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
openblas - 0.3 .3 - r2[so: libgfortran.so .5]
The command '/bin/sh -c apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev'
returned a non - zero code: 4

Here's the new Dockerfile

FROM alpine: 3.4
RUN echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > /etc/apk / repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk / repositories
RUN apk--no - cache--update - cache add gcc gfortran python python - dev py - pip build - base wget freetype - dev libpng - dev openblas - dev
RUN ln - s / usr / include / locale.h / usr / include / xlocale.h
RUN pip install numpy scipy pandas matplotlib

This works for me:

FROM: python: alpine

RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk / repositories

# Add HDF5 support
RUN apk add--no - cache--allow - untrusted--repository http: //dl-3.alpinelinux.org/alpine/edge/testing hdf5 hdf5-dev
   RUN apk--no - cache--update - cache add gcc gfortran python python - dev py - pip build - base wget freetype - dev libpng - dev openblas - dev
RUN ln - s / usr / include / locale.h / usr / include / xlocale.h

RUN pip install numpy
$ docker run - it python: 3 - alpine sh /
   # apk add--update--no - cache py3 - numpy
   ...
   / # python >>>
   import numpy >>>
   ...module not found...
   >>>
   import sys >>>
   sys.path['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']

Suggestion : 3

Scikit Learn Install Failure Numpy Not Found Missing Numpy Headers,Apparently all the numpy headers in "site-packages/numpy/core/include" are missing. I already reinstalled numpy with pip without any Problems but the headers are still missing., First you need to install numpy and scipy from their own official installers. Wheel packages (.whl files) for scikit-learn from PyPI can be installed with the pip utility. Open a console and type the following to install or upgrade scikit-learn to the latest stable release: , Scikit-learn can also be tested without having the package installed. For this you must compile the sources inplace from the source directory: You can also install a symlink named site-packages/scikit-learn.egg-link to the development folder of scikit-learn with:


pip install - U scikit - learn
pip install - U scikit - learn
(....) compile options: '-I/usr/lib64/python2.7/site-packages/numpy/core/include -Isklearn/svm/src/libsvm -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'
gcc: sklearn / svm / libsvm.c sklearn / svm / libsvm.c: 303: 31: fatal error: numpy / arrayobject.h: No such file or directory compilation terminated.sklearn / svm / libsvm.c: 303: 31: fatal error: numpy / arrayobject.h: No such file or directory compilation terminated.
adding 'build/src.linux-x86_64-2.7/fortranobject.c'
to sources.adding 'build/src.linux-x86_64-2.7'
to include_dirs.error: file '/usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c'
does not exist