Starting a flask app on my raspberry pi 4 in a docker container crashes with scikit-learn (OS: Linux raspberrypi 5.10.103-v7l+ armv7l GNU/Linux)

I am trying to set up a website on a flask server on my raspberry pi 4 (OS: Linux raspberrypi 5.10.103-v7l+ armv7l GNU/Linux). The flask app runs in two docker containers (one database, one the app). On the mac, the webapp works fine. When I try to build the containers on the raspi (using docker-compose), the built-process stops when it comes to the installing process of scikit-learn in my requirements.txt - file. I tried the process with different official docker python-images such as: buster, bullseye, alpine, slim-buster. All on python 3.10 and 3.9 but none of these worked and all of them crashed when installing scikit-learn. I used as well python3-sklearn which was mentioned as standard for debian, but this wasn't even found:

error: Could not find a version that satisfies the requirement python3-sklearn (from versions: none)

The webapp was developped and runs originally on python 3.10 on the mac. I am still a newbie and does not know exactly which dependencies are available in which python distribution and which distribution runs perfectly on the raspi.

The standard error when trying to install the dependency scikit-learn is:

    Step 5/7 : RUN pip install -r requirements.txt
 ---> Running in 80aa4d394636
Collecting scikit-learn
  Downloading scikit-learn-1.0.2.tar.gz (6.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.7/6.7 MB 4.7 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: finished with status 'error'
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [238 lines of output]
      Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64" and platform_system != "AIX" and platform_python_implementation != "PyPy"' don't match your environment
      Collecting setuptools<60.0
        Downloading setuptools-59.8.0-py3-none-any.whl (952 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 952.8/952.8 KB 2.4 MB/s eta 0:00:00
      Collecting wheel
        Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
      Collecting Cython>=0.28.5
        Downloading Cython-0.29.28-py2.py3-none-any.whl (983 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 983.8/983.8 KB 4.8 MB/s eta 0:00:00
      Collecting oldest-supported-numpy
        Downloading oldest_supported_numpy-2022.4.18-py3-none-any.whl (3.9 kB)
      Collecting scipy>=1.1.0
        Downloading scipy-1.8.0.tar.gz (38.3 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.3/38.3 MB 1.6 MB/s eta 0:00:00
        Installing build dependencies: started
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: still running...
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): still running...
        Preparing metadata (pyproject.toml): still running...
        Preparing metadata (pyproject.toml): still running...
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error
      
        × Preparing metadata (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [192 lines of output]
            setup.py:482: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-modern-metadata-lawh_nrs'), proceeding with generating Cython sources and expanding templates
              warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
            Running from SciPy source directory.
            /tmp/pip-install-sswhqewq/scipy_9e1fec7b09d143e3a2c5d8cc519ad881/scipy/linalg/_generate_pyx.py:674: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
              from distutils.dep_util import newer
            /tmp/pip-install-sswhqewq/scipy_9e1fec7b09d143e3a2c5d8cc519ad881/scipy/special/_generate_pyx.py:1443: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
              from distutils.dep_util import newer
            Running scipy/linalg/_generate_pyx.py
            Running scipy/special/_generate_pyx.py
            Running scipy/stats/_generate_pyx.py
            Processing scipy/spatial/_voronoi.pyx
            Processing scipy/spatial/_hausdorff.pyx
            Processing scipy/spatial/_ckdtree.pyx
            Processing scipy/spatial/_qhull.pyx
            Processing scipy/spatial/transform/_rotation.pyx
            Processing scipy/optimize/_bglu_dense.pyx
            Processing scipy/optimize/_group_columns.pyx
            Processing scipy/optimize/cython_optimize/_zeros.pyx.in
            Processing scipy/optimize/tnc/_moduleTNC.pyx
            Processing scipy/optimize/_trlib/_trlib.pyx
            Processing scipy/optimize/_highs/cython/src/_highs_wrapper.pyx
            Processing scipy/optimize/_highs/cython/src/_highs_constants.pyx
            Processing scipy/optimize/_lsq/givens_elimination.pyx
            Processing scipy/linalg/_decomp_update.pyx.in
            Processing scipy/linalg/cython_blas.pyx
            Processing scipy/linalg/_matfuncs_sqrtm_triu.pyx
            Processing scipy/linalg/_solve_toeplitz.pyx
            Processing scipy/linalg/cython_lapack.pyx
            Processing scipy/linalg/_cythonized_array_utils.pyx
            Processing scipy/cluster/_vq.pyx
            Processing scipy/cluster/_optimal_leaf_ordering.pyx
            Processing scipy/cluster/_hierarchy.pyx
            Processing scipy/special/_test_round.pyx
            Processing scipy/special/cython_special.pyx
            Processing scipy/special/_ellip_harm_2.pyx
            Processing scipy/special/_comb.pyx
            Processing scipy/special/_ufuncs.pyx
            Processing scipy/special/_ufuncs_cxx.pyx
            Processing scipy/fftpack/convolve.pyx
            Processing scipy/sparse/_csparsetools.pyx.in
            Processing scipy/sparse/csgraph/_reordering.pyx
            Processing scipy/sparse/csgraph/_matching.pyx
            Processing scipy/sparse/csgraph/_traversal.pyx
            Processing scipy/sparse/csgraph/_shortest_path.pyx
            Processing scipy/sparse/csgraph/_min_spanning_tree.pyx
            Processing scipy/sparse/csgraph/_tools.pyx
            Processing scipy/sparse/csgraph/_flow.pyx
            Processing scipy/stats/_stats.pyx
            Processing scipy/stats/_sobol.pyx
            Processing scipy/stats/_qmc_cy.pyx
            Processing scipy/stats/_biasedurn.pyx
            Processing scipy/stats/_boost/src/binom_ufunc.pyx
            Processing scipy/stats/_boost/src/beta_ufunc.pyx
            Processing scipy/stats/_boost/src/nbinom_ufunc.pyx
            Processing scipy/stats/_boost/src/hypergeom_ufunc.pyx
            Processing scipy/stats/_unuran/unuran_wrapper.pyx
            Processing scipy/signal/_peak_finding_utils.pyx
            Processing scipy/signal/_sosfilt.pyx
            Processing scipy/signal/_upfirdn_apply.pyx
            warning: unuran_wrapper.pyx:470:21: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:470:28: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:470:36: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:515:21: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:515:28: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:515:36: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:1476:21: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:1476:28: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            warning: unuran_wrapper.pyx:1476:36: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
            Processing scipy/signal/_max_len_seq_inner.pyx
            Processing scipy/signal/_spectral.pyx
            Processing scipy/io/matlab/_mio5_utils.pyx
            Processing scipy/io/matlab/_mio_utils.pyx
            Processing scipy/io/matlab/_streams.pyx
            Processing scipy/_lib/_test_deprecation_call.pyx
            Processing scipy/_lib/messagestream.pyx
            Processing scipy/_lib/_ccallback_c.pyx
            Processing scipy/_lib/_test_deprecation_def.pyx
            Processing scipy/interpolate/interpnd.pyx
            Processing scipy/interpolate/_ppoly.pyx
            Processing scipy/interpolate/_bspl.pyx
            Processing scipy/ndimage/src/_ni_label.pyx
            Processing scipy/ndimage/src/_cytest.pyx
            Cythonizing sources
            lapack_opt_info:
            lapack_mkl_info:
            customize UnixCCompiler
              libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
              NOT AVAILABLE
      
            openblas_lapack_info:
              libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
              NOT AVAILABLE
      
            openblas_clapack_info:
              libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
              NOT AVAILABLE
      
            flame_info:
              libraries flame not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
              NOT AVAILABLE
      
            accelerate_info:
              NOT AVAILABLE
      
            atlas_3_10_threads_info:
            Setting PTATLAS=ATLAS
              libraries lapack_atlas not found in /usr/local/lib
              libraries tatlas,tatlas not found in /usr/local/lib
              libraries lapack_atlas not found in /usr/lib
              libraries tatlas,tatlas not found in /usr/lib
              libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
              libraries tatlas,tatlas not found in /usr/lib/arm-linux-gnueabihf
            <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
              NOT AVAILABLE
      
            atlas_3_10_info:
              libraries lapack_atlas not found in /usr/local/lib
              libraries satlas,satlas not found in /usr/local/lib
              libraries lapack_atlas not found in /usr/lib
              libraries satlas,satlas not found in /usr/lib
              libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
              libraries satlas,satlas not found in /usr/lib/arm-linux-gnueabihf
            <class 'numpy.distutils.system_info.atlas_3_10_info'>
              NOT AVAILABLE
      
            atlas_threads_info:
            Setting PTATLAS=ATLAS
              libraries lapack_atlas not found in /usr/local/lib
              libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
              libraries lapack_atlas not found in /usr/lib
              libraries ptf77blas,ptcblas,atlas not found in /usr/lib
              libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
              libraries ptf77blas,ptcblas,atlas not found in /usr/lib/arm-linux-gnueabihf
            <class 'numpy.distutils.system_info.atlas_threads_info'>
              NOT AVAILABLE
      
            atlas_info:
              libraries lapack_atlas not found in /usr/local/lib
              libraries f77blas,cblas,atlas not found in /usr/local/lib
              libraries lapack_atlas not found in /usr/lib
              libraries f77blas,cblas,atlas not found in /usr/lib
              libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
              libraries f77blas,cblas,atlas not found in /usr/lib/arm-linux-gnueabihf
            <class 'numpy.distutils.system_info.atlas_info'>
              NOT AVAILABLE
      
            lapack_info:
              libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
              NOT AVAILABLE
      
            /tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/numpy/distutils/system_info.py:1858: 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.
              return getattr(self, '_calc_info_{}'.format(name))()
            lapack_src_info:
              NOT AVAILABLE
      
            /tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/numpy/distutils/system_info.py:1858: 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.
              return getattr(self, '_calc_info_{}'.format(name))()
              NOT AVAILABLE
      
            Traceback (most recent call last):
              File "/tmp/tmpya4opka6_in_process.py", line 363, in <module>
                main()
              File "/tmp/tmpya4opka6_in_process.py", line 345, in main
                json_out['return_val'] = hook(**hook_input['kwargs'])
              File "/tmp/tmpya4opka6_in_process.py", line 164, in prepare_metadata_for_build_wheel
                return hook(metadata_directory, config_settings)
              File "/tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in prepare_metadata_for_build_wheel
                self.run_setup()
              File "/tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 267, in run_setup
                super(_BuildMetaLegacyBackend,
              File "/tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
                exec(compile(code, __file__, 'exec'), locals())
              File "setup.py", line 626, in <module>
                setup_package()
              File "setup.py", line 622, in setup_package
                setup(**metadata)
              File "/tmp/pip-build-env-0ttxic2q/overlay/lib/python3.10/site-packages/numpy/distutils/core.py", line 135, in setup
                config = configuration()
              File "setup.py", line 522, in configuration
                raise NotFoundError(msg)
            numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found.
            To build Scipy from sources, BLAS & LAPACK libraries need to be installed.
            See site.cfg.example in the Scipy source directory and
            https://docs.scipy.org/doc/scipy/reference/building/index.html for details.
            [end of output]
      
        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed
      
      × Encountered error while generating package metadata.
      ╰─> See above for output.
      
      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output

So my question is, which package could I use or which image could be the right. I don't understand how the package itself could be found but some specifics inside are "NOT AVAILABLE". What am I misunderstanding?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum