RasberryPi+Docker+Python3.7にpython-controlを入れるときのDockerfileの書き方

2022年12月23日

手順

Dockerfileを下記のように記述すれば、python-controlをインストールできた

FROM python:3.7
RUN apt-get update
RUN apt-get install -y ninja-build gfortran libblas-dev liblapack-dev
RUN pip install --upgrade pip
RUN pip install control slycot

RUN pip install control slycotだけ追加した時に出たエラー

コピペミスでインデントがおかしいが、下記の内容のエラーが出る。

Collecting slycot 
Downloading slycot-0.4.0.0.tar.gz (1.5 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'  
Getting requirements to build wheel: started

Getting requirements to build wheel: finished with status 'done'  
Preparing wheel metadata: started 
Preparing wheel metadata: finished with status 'done'
Collecting starlette==0.17.1
Downloading starlette-0.17.1-py3-none-any.whl (58 kB)
Collecting anyio<4,>=3.0.0
Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
Collecting typing-extensions
Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)  
Collecting asgiref>=3.4.0
  Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting click>=7.0
  Downloading click-8.0.3-py3-none-any.whl (97 kB)
 Collecting h11>=0.8
Downloading h11-0.13.0-py3-none-any.whl (58 kB)
  Collecting greenlet!=0.4.17
Downloading greenlet-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (150 kB)
Collecting importlib-metadata
  Downloading importlib_metadata-4.10.1-py3-none-any.whl (17 kB)Collecting urllib3<1.27,>=1.21.1Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)  Collecting charset-normalizer~=2.0.0Downloading charset_normalizer-2.0.10-py3-none-any.whl (39 kB)Collecting idna<4,>=2.5
Downloading idna-3.3-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)Collecting numpy  Using cached numpy-1.21.5-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Collecting scipy  Downloading scipy-1.7.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (38.1 MB) Collecting matplotlib
  Downloading matplotlib-3.5.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)Collecting sniffio>=1.1
Downloading sniffio-1.2.0-py3-none-any.whl (10 kB)
Collecting zipp>=0.5
Downloading zipp-3.7.0-py3-none-any.whl (5.3 kB)
 Collecting packaging>=20.0
 Using cached packaging-21.3-py3-none-any.whl (40 kB)
 Collecting pyparsing>=2.2.1
Using cached pyparsing-3.0.6-py3-none-any.whl (97 kB)
Collecting python-dateutil>=2.7
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.3.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB) Collecting fonttools>=4.22.0
Downloading fonttools-4.28.5-py3-none-any.whl (890 kB)Collecting cycler>=0.10
Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
  Collecting pillow>=6.2.0
Downloading Pillow-9.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB) Collecting six>=1.5
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
  Building wheels for collected packages: control, slycot
  Building wheel for control (setup.py): started
 Building wheel for control (setup.py): finished with status 'done'  Created wheel for control: filename=control-0.9.1-py2.py3-none-any.whl size=364705 sha256=2064df092b357b2ad523e32138d625803084bd99aa4fdc7a72f47e5ad3defb27Stored in directory: /root/.cache/pip/wheels/b1/50/22/8005107713828997d1af664fbd629c7f935a1b87fc2f4ba6c1
Building wheel for slycot (PEP 517): started
Building wheel for slycot (PEP 517): finished with status 'error'ERROR: Command errored out with exit status 1:
  command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpy3cnp5wz
  cwd: /tmp/pip-install-b9rfvlyl/slycot_fcc85b1b1c49408e9dbfa68ac11ce766
  Complete output (83 lines):
  Not searching for unused variables given on the command line.CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-b9rfvlyl/slycot_fcc85b1b1c49408e9dbfa68ac11ce766/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".  Not searching for unused variables given on the command line.-- The C compiler identification is GNU 10.2.1
 -- Detecting C compiler ABI info  -- Detecting C compiler ABI info - done-- Check for working C compiler: /usr/bin/cc - skipped
 -- Detecting C compile features-- Detecting C compile features - done-- The Fortran compiler identification is unknown
  CMake Error at CMakeLists.txt:4 (ENABLE_LANGUAGE):
No CMAKE_Fortran_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
  variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-b9rfvlyl/slycot_fcc85b1b1c49408e9dbfa68ac11ce766/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".  See also "/tmp/pip-install-b9rfvlyl/slycot_fcc85b1b1c49408e9dbfa68ac11ce766/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
--------------------------------------------------------------------------------
 -- Trying "Ninja" generator
  --------------------------------  ---------------------------
  ----------------------
-----------------
------------------- --
 --
 ------- -----------------------------
----------------------
---------------------------
  --------------------------------  -- Trying "Ninja" generator - failure --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 -- Trying "Unix Makefiles" generator  --------------------------------  ---------------------------
  ----------------------
-----------------
------------------- --
 --
 ------- -----------------------------
----------------------
---------------------------
  --------------------------------  -- Trying "Unix Makefiles" generator - failure
 --------------------------------------------------------------------------------********************************************************************************
 scikit-build could not get a working generator for your system. Aborting build. Building Linux wheels for Python 3.7 requires a compiler (e.g gcc). It can be installed using debian package manager:sudo apt-get install build-essential
To build compliant wheels, consider using the manylinux system described in PEP-513.  Get it with "dockcross/manylinux-x64" docker image: https://github.com/dockcross/dockcross#readmeFor more details, please refer to scikit-build documentation:
http://scikit-build.readthedocs.io/en/latest/generators.html#linux
********************************************************************************
 ----------------------------------------  ERROR: Failed building wheel for slycot Successfully built control
Failed to build slycot
ERROR: Could not build wheels for slycot which use PEP 517 and cannot be installed directlyWARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.