scipy: Not able to install scipy using pip in docker alpine image with python:3.5.6-alpine image
I am not able to install pip install scipy
in docker alpine:3.8
image
this is my Dockerfile
FROM alpine:3.8
FROM python:3.5.6-alpine
COPY requirements.txt /requirements.txt
RUN pip install /requirements.txt
requirements.txt
has 2 libs
numpy==1.14.3
scipy==1.0.1
Reproducing code example:
Run the above Dockerfile and install `numpy==1.14.3` and `scipy==1.0.1` using `pip` to get the error
Error message:
/ # pip install scipy==1.0.1
Collecting scipy==1.0.1
Downloading https://files.pythonhosted.org/packages/bd/f4/3882758754dc083fea6ea66a6e8ceef55e7df173d06a12a074612958800f/scipy-1.0.1.tar.gz (15.5MB)
100% |████████████████████████████████| 15.5MB 853kB/s
Building wheels for collected packages: scipy
Running setup.py bdist_wheel for scipy ... error
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-gk51lyjw/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-fb9a05i5 --python-tag cp35:
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
openblas_lapack_info:
customize UnixCCompiler
customize UnixCCompiler
libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
openblas_clapack_info:
customize UnixCCompiler
customize UnixCCompiler
libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
NOT AVAILABLE
atlas_3_10_info:
customize UnixCCompiler
libraries satlas,satlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries satlas,satlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries satlas,satlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_3_10_info'>
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_threads_info'>
NOT AVAILABLE
atlas_info:
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_info'>
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
lapack_info:
customize UnixCCompiler
libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
self.calc_info()
lapack_src_info:
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
self.calc_info()
NOT AVAILABLE
Running from scipy source directory.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 418, in <module>
setup_package()
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 414, in setup_package
setup(**metadata)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 336, in configuration
config.add_subpackage('scipy')
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/setup.py", line 15, in configuration
config.add_subpackage('linalg')
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/linalg/setup.py", line 19, in configuration
raise NotFoundError('no lapack/blas resources found')
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
----------------------------------------
Failed building wheel for scipy
Running setup.py clean for scipy
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-gk51lyjw/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
`setup.py clean` is not supported, use one of the following instead:
- `git clean -xdf` (cleans all files)
- `git clean -Xdf` (cleans all versioned files, doesn't touch
files that aren't checked into the git repo)
Add `--force` to your command to use it anyway if you must (unsupported).
----------------------------------------
Failed cleaning build dir for scipy
Failed to build scipy
Installing collected packages: scipy
Running setup.py install for scipy ... error
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-gk51lyjw/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ag4dsjlb/install-record.txt --single-version-externally-managed --compile:
Note: if you need reliable uninstall behavior, then install
with pip instead of using `setup.py install`:
- `pip install .` (from a git repo or downloaded source
release)
- `pip install scipy` (last SciPy release on PyPI)
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
openblas_lapack_info:
customize UnixCCompiler
customize UnixCCompiler
libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
openblas_clapack_info:
customize UnixCCompiler
customize UnixCCompiler
libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries tatlas,tatlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
NOT AVAILABLE
atlas_3_10_info:
customize UnixCCompiler
libraries satlas,satlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries satlas,satlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries satlas,satlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_3_10_info'>
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries ptf77blas,ptcblas,atlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_threads_info'>
NOT AVAILABLE
atlas_info:
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/local/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/local/lib
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/lib
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib
customize UnixCCompiler
libraries f77blas,cblas,atlas not found in /usr/lib/
customize UnixCCompiler
libraries lapack_atlas not found in /usr/lib/
<class 'numpy.distutils.system_info.atlas_info'>
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
lapack_info:
customize UnixCCompiler
libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
self.calc_info()
lapack_src_info:
NOT AVAILABLE
/usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:624: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
self.calc_info()
NOT AVAILABLE
Running from scipy source directory.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 418, in <module>
setup_package()
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 414, in setup_package
setup(**metadata)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "/tmp/pip-install-gk51lyjw/scipy/setup.py", line 336, in configuration
config.add_subpackage('scipy')
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/setup.py", line 15, in configuration
config.add_subpackage('linalg')
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/linalg/setup.py", line 19, in configuration
raise NotFoundError('no lapack/blas resources found')
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-gk51lyjw/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ag4dsjlb/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-gk51lyjw/scipy/
Scipy/Numpy/Python version information:
>>> print(numpy.__version__, sys.version_info)
1.14.3 sys.version_info(major=3, minor=5, micro=6, releaselevel='final', serial=0)
/ # python -V
Python 3.5.6
/ # pip -V
pip 18.1 from /usr/local/lib/python3.5/site-packages/pip (python 3.5)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 65
- Comments: 31 (9 by maintainers)
Links to this issue
Commits related to this issue
- fix - reduce numpy version to 1.17.3 https://github.com/scipy/scipy/issues/9481 — committed to bitwyre/base-images by dendisuhubdy 4 years ago
- fix - reduce numpy version to 1.17.3 (#79) * fix - reduce numpy version to 1.17.3 https://github.com/scipy/scipy/issues/9481 * fix - add Pythonpath https://github.com/matthewfeickert/python3... — committed to bitwyre/base-images by dendisuhubdy 4 years ago
- downgrade python image until scipy issue is fixed. see https://github.com/scipy/scipy/issues/9481 — committed to chinchalinchin/scrilla by chinchalinchin 3 years ago
looks like the confusion is cleared up here, and there’s no scipy bug. so I’ll close this issue. feel free to continue adding information if that seems useful of course.
thanks all
#Apologies for the delayed response
As @rgommers stated scipy doesn’t maintain a docker image rather they have an alpine package
py3-scipy
But I was able to install scipy on python3.8 with alpine3.11 with below DockerfileYou can even use base apline:3.11 to install scipy also
This worked for me
RUN apk --no-cache add lapack libstdc++ && apk --no-cache add --virtual .builddeps g++ gcc gfortran musl-dev lapack-dev && pip install scipy && apk del .builddeps && rm -rf /root/.cache
Hey @reddimohan , @itayB, I’ve been able to install
scipy
onpython:3.7.3-alpine
docker image.method one
First, I’ve installed
openblas
in order to generate shared objects.You need to install
gfortran
andperl
.Next, you need to run your scipy installation like:
It’s taking a while (not as long as firefox on Gentoo 😂 ), but as @ilayn said there is no wheel for alpine, so alpine will compile.
You’ve built your own lib, so you need to add it to the linker path:
method two
There is also another way: you can download directly
scipy
sources and patch numpy installation.Then create edit
site.cfg
(there is an example), like this one:I’ve personally used the first method, because
numpy
was already installed and patched to use openblas.I don’t know yet if every scipy features work as expected, but I’ve successfully installed scipy and imported it.
This looks like manylinux wheels are not compatible with Alpine (whatever distro it might be) and it is trying to build it. However then it also needs lapack and blas sources you can find the required libraries here.
I can confirm on alpine 3.11,
numpy==1.17.3
andscipy==1.3.1
can be installed directly through pip no need to build the package. You will need to make sure you havelibgcc, libquadmath, musl, libgfortran, lapack-dev
pip install scipy==1.3.1
Do you need to build SciPy, or does the Alpine
py3-scipy
(which currently has 1.3.3, and will probably update soon) work? See https://pkgs.alpinelinux.org/packages?name=py3-scipy&branch=edgeIt worked for me too, I was just confused with ‘&&’ and ‘\’ usage! Thanks @shivam-kotwalia!
Dockerfile:
Requirements:
@itayB You can ask for the pypi wheel by
pip install scipy
hence you don’t need to build but otherwise please check the link I’ve pasted above at the endI’ve been also able to install scikit learn with solution proposed by @shivam-kotwalia. It takes me 1 hour to install though…
Thank you very much for kindly pointing this out to me @rgommers. Indeed, this will work fine. I apologize for not doing a better job of searching the available Alpine resources before diving into trying to build
scipy
.1.3.2, which will be out sooner (within 1-2 weeks I think), will also be Python 3.8 compatible.
For now, building from master is your only option for py38. That will be true for other packages too, use 3.7 if you want to make your life easier.
@rgommers scipy is breaking docker usage.
@reddimohan did you fix it? can you share the solution?
This worked for me.
@matthewfeickert This actually helped me a ton today! Thxs for posting!
No it’s not, this is specific to Alpine because it chose with the unusual musl libc. No wheels on PyPI for any package containing compiled code will work with it. If you use Alpine Linux, you’re signing up to building everything from scratch. Or just use conda, which includes glibc so should work.
Thanks, @tormath1, I will try your solution and let you know the progress.