Numpy installation failing on Google Coral

I’m trying to run a computer vision server on google coral through balena. When I try to install some of the dependencies, namely NumPy, I get this long error:

[main]     Step 4/13 : RUN sudo pip3 install numpy
[main]      ---> Running in c64cb089792e
[main]     Collecting numpy
[main]       Downloading numpy-1.18.5.zip (5.4 MB)
[main]       Installing build dependencies: started
[main]       Installing build dependencies: finished with status 'done'
[main]       Getting requirements to build wheel: started
[main]       Getting requirements to build wheel: finished with status 'done'
[main]         Preparing wheel metadata: started
[main]         Preparing wheel metadata: finished with status 'error'
[main]         ERROR: Command errored out with exit status 1:
[main]          command: /usr/local/bin/python3.5 /usr/local/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp43_oejbq
[main]              cwd: /tmp/pip-install-fywn2bkh/numpy
[main]         Complete output (222 lines):
[main]         Processing numpy/random/_bounded_integers.pxd.in
[main]         Processing numpy/random/_generator.pyx
[main]         Processing numpy/random/_common.pyx
[main]         Processing numpy/random/_mt19937.pyx
[main]         Processing numpy/random/mtrand.pyx
[main]         Processing numpy/random/_bit_generator.pyx
[main]         Processing numpy/random/_philox.pyx
[main]         Processing numpy/random/_pcg64.pyx
[main]         Processing numpy/random/_sfc64.pyx
[main]         Processing numpy/random/_bounded_integers.pyx.in
[main]         Cythonizing sources
[main]         blas_opt_info:
[main]         blas_mkl_info:
[main]         customize UnixCCompiler
[main]           libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         blis_info:
[main]           libraries blis not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         openblas_info:
[main]           libraries openblas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         atlas_3_10_blas_threads_info:
[main]         Setting PTATLAS=ATLAS
[main]           libraries tatlas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         atlas_3_10_blas_info:
[main]           libraries satlas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         atlas_blas_threads_info:
[main]         Setting PTATLAS=ATLAS
[main]           libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         atlas_blas_info:
[main]           libraries f77blas,cblas,atlas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         accelerate_info:
[main]           NOT AVAILABLE
[main]         blas_info:
[main]           libraries blas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         blas_src_info:
[main]           NOT AVAILABLE
[main]           NOT AVAILABLE
[main]         non-existing path in 'numpy/distutils': 'site.cfg'
[main]         lapack_opt_info:
[main]         lapack_mkl_info:
[main]           libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         openblas_lapack_info:
[main]           libraries openblas not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         openblas_clapack_info:
[main]           libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         flame_info:
[main]           libraries flame not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         atlas_3_10_threads_info:
[main]         Setting PTATLAS=ATLAS
[main]           libraries lapack_atlas not found in /usr/local/lib
[main]           libraries tatlas,tatlas not found in /usr/local/lib
[main]           libraries lapack_atlas not found in /usr/lib
[main]           libraries tatlas,tatlas not found in /usr/lib
[main]         <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
[main]           NOT AVAILABLE
[main]         atlas_3_10_info:
[main]           libraries lapack_atlas not found in /usr/local/lib
[main]           libraries satlas,satlas not found in /usr/local/lib
[main]           libraries lapack_atlas not found in /usr/lib
[main]           libraries satlas,satlas not found in /usr/lib
[main]         <class 'numpy.distutils.system_info.atlas_3_10_info'>
[main]           NOT AVAILABLE
[main]         atlas_threads_info:
[main]         Setting PTATLAS=ATLAS
[main]           libraries lapack_atlas not found in /usr/local/lib
[main]           libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
[main]           libraries lapack_atlas not found in /usr/lib
[main]           libraries ptf77blas,ptcblas,atlas not found in /usr/lib
[main]         <class 'numpy.distutils.system_info.atlas_threads_info'>
[main]           NOT AVAILABLE
[main]         atlas_info:
[main]           libraries lapack_atlas not found in /usr/local/lib
[main]           libraries f77blas,cblas,atlas not found in /usr/local/lib
[main]           libraries lapack_atlas not found in /usr/lib
[main]           libraries f77blas,cblas,atlas not found in /usr/lib
[main]         <class 'numpy.distutils.system_info.atlas_info'>
[main]           NOT AVAILABLE
[main]         lapack_info:
[main]           libraries lapack not found in ['/usr/local/lib', '/usr/lib']
[main]           NOT AVAILABLE
[main]         lapack_src_info:
[main]           NOT AVAILABLE
[main]           NOT AVAILABLE
[main]         running dist_info
[main]         running build_src
[main]         build_src
[main]         building py_modules sources
[main]         creating build
[main]         creating build/src.linux-aarch64-3.5
[main]         creating build/src.linux-aarch64-3.5/numpy
[main]         creating build/src.linux-aarch64-3.5/numpy/distutils
[main]         building library "npymath" sources
[main]         Could not locate executable gfortran
[main]         Could not locate executable f95
[main]         Could not locate executable ifort
[main]         Could not locate executable ifc
[main]         Could not locate executable lf95
[main]         Could not locate executable pgfortran
[main]         Could not locate executable f90
[main]         Could not locate executable f77
[main]         Could not locate executable fort
[main]         Could not locate executable efort
[main]         Could not locate executable efc
[main]         Could not locate executable g77
[main]         Could not locate executable g95
[main]         Could not locate executable pathf95
[main]         Could not locate executable nagfor
[main]         don't know how to compile Fortran code on platform 'posix'
[main]         Running from numpy source directory.
[main]         setup.py:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
[main]           run_build = parse_setuppy_commands()
[main]         /tmp/pip-install-fywn2bkh/numpy/numpy/distutils/system_info.py:1896: UserWarning:
[main]             Optimized (vendor) Blas libraries are not found.
[main]             Falls back to netlib Blas library which has worse performance.
[main]             A better performance should be easily gained by switching
[main]             Blas library.
[main]           if self._calc_info(blas):
[main]         /tmp/pip-install-fywn2bkh/numpy/numpy/distutils/system_info.py:1896: UserWarning:
[main]             Blas (http://www.netlib.org/blas/) libraries not found.
[main]             Directories to search for the libraries can be specified in the
[main]             numpy/distutils/site.cfg file (section [blas]) or by setting
[main]             the BLAS environment variable.
[main]           if self._calc_info(blas):
[main]         /tmp/pip-install-fywn2bkh/numpy/numpy/distutils/system_info.py:1896: UserWarning:
[main]             Blas (http://www.netlib.org/blas/) sources not found.
[main]             Directories to search for the sources can be specified in the
[main]             numpy/distutils/site.cfg file (section [blas_src]) or by setting
[main]             the BLAS_SRC environment variable.
[main]           if self._calc_info(blas):
[main]         /tmp/pip-install-fywn2bkh/numpy/numpy/distutils/system_info.py:1730: UserWarning:
[main]             Lapack (http://www.netlib.org/lapack/) libraries not found.
[main]             Directories to search for the libraries can be specified in the
[main]             numpy/distutils/site.cfg file (section [lapack]) or by setting
[main]             the LAPACK environment variable.
[main]           return getattr(self, '_calc_info_{}'.format(name))()
[main]         /tmp/pip-install-fywn2bkh/numpy/numpy/distutils/system_info.py:1730: UserWarning:
[main]             Lapack (http://www.netlib.org/lapack/) sources not found.
[main]             Directories to search for the sources can be specified in the
[main]             numpy/distutils/site.cfg file (section [lapack_src]) or by setting
[main]             the LAPACK_SRC environment variable.
[main]           return getattr(self, '_calc_info_{}'.format(name))()
[main]         /usr/local/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
[main]           warnings.warn(msg)
[main]         Traceback (most recent call last):
[main]           File "/usr/local/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
[main]             main()
[main]           File "/usr/local/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
[main]             json_out['return_val'] = hook(**hook_input['kwargs'])
[main]           File "/usr/local/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
[main]             return hook(metadata_directory, config_settings)
[main]           File "/tmp/pip-build-env-6ujbii8j/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 157, in prepare_metadata_for_build_wheel
[main]             self.run_setup()
[main]           File "/tmp/pip-build-env-6ujbii8j/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 249, in run_setup
[main]             self).run_setup(setup_script=setup_script)
[main]           File "/tmp/pip-build-env-6ujbii8j/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 142, in run_setup
[main]             exec(compile(code, __file__, 'exec'), locals())
[main]           File "setup.py", line 488, in <module>
[main]             setup_package()
[main]           File "setup.py", line 480, in setup_package
[main]             setup(**metadata)
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/core.py", line 171, in setup
[main]             return old_setup(**new_attr)
[main]           File "/tmp/pip-build-env-6ujbii8j/overlay/lib/python3.5/site-packages/setuptools/__init__.py", line 161, in setup
[main]             return distutils.core.setup(**attrs)
[main]           File "/usr/local/lib/python3.5/distutils/core.py", line 148, in setup
[main]             dist.run_commands()
[main]           File "/usr/local/lib/python3.5/distutils/dist.py", line 955, in run_commands
[main]             self.run_command(cmd)
[main]           File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
[main]             cmd_obj.run()
[main]           File "/tmp/pip-build-env-6ujbii8j/overlay/lib/python3.5/site-packages/setuptools/command/dist_info.py", line 31, in run
[main]             egg_info.run()
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/command/egg_info.py", line 26, in run
[main]             self.run_command("build_src")
[main]           File "/usr/local/lib/python3.5/distutils/cmd.py", line 313, in run_command
[main]             self.distribution.run_command(command)
[main]           File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
[main]             cmd_obj.run()
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/command/build_src.py", line 146, in run
[main]             self.build_sources()
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/command/build_src.py", line 157, in build_sources
[main]             self.build_library_sources(*libname_info)
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/command/build_src.py", line 290, in build_library_sources
[main]             sources = self.generate_sources(sources, (lib_name, build_info))
[main]           File "/tmp/pip-install-fywn2bkh/numpy/numpy/distutils/command/build_src.py", line 380, in generate_sources
[main]             source = func(extension, build_dir)
[main]           File "numpy/core/setup.py", line 661, in get_mathlib_info
[main]             raise RuntimeError("Broken toolchain: cannot link a simple C program")
[main]         RuntimeError: Broken toolchain: cannot link a simple C program
[main]         ----------------------------------------
[main]
[main]     ERROR: Command errored out with exit status 1: /usr/local/bin/python3.5 /usr/local/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp43_oejbq Check the logs for full command output.

Here is my dockerfile:

# base-image for python on any machine using a template variable,
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/
FROM balenalib/coral-dev-python:3-stretch-run


# Set our working directory
WORKDIR /usr/src/app





RUN pip3 install --upgrade pip
RUN sudo pip3 install numpy
RUN sudo pip3 install Pillow>=4.0.0
RUN sudo pip3 install pygobject>=3.22.0
RUN sudo pip3 install protobuf>=3.0.0
RUN sudo pip3 install edgetpu
RUN sudo pip3 install littleutils
RUN sudo pip3 install requests

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.
ENV UDEV=1

CMD ["python3","-m","Reef_Vision/detect_server.py"]

Any help would be greatly appreciated, I’m new to using containers.

Hi,
I think it may be a compatibility issue between numpy and python versions.
From the stack trace you posted, it looks like python 3.5 is used.
At the same time, you seem to install the latest version of numpy (not specifying the version), and it’s requirement is python >=3.6

I would suggest trying to change the parent image tag in your docker file from balenalib/coral-dev-python:3-stretch-run to balenalib/coral-dev-python:3.6-stretch-run. That said, we should figure out why this 3-stretch-run tag does not point to the latest Python version.

First of all, thanks for your help! I was able to get numpy to install with your suggestion. However, this unearthed some new issues. Pillow and pygobject both failed, and edgetpu was not found by pip.
Pillow:

[main]     Step 5/13 : RUN sudo pip3 install Pillow
[main]      ---> Running in 79743a879ada
[main]     Collecting Pillow
[main]       Downloading Pillow-7.1.2.tar.gz (38.9 MB)
[main]     Using legacy setup.py install for Pillow, since package 'wheel' is not installed.
[main]     Installing collected packages: Pillow
[main]         Running setup.py install for Pillow: started
[main]         Running setup.py install for Pillow: finished with status 'error'
[main]         ERROR: Command errored out with exit status 1:
[main]          command: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6weg3wc5/Pillow/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6weg3wc5/Pillow/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-y5r7101v/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/Pillow
[main]              cwd: /tmp/pip-install-6weg3wc5/Pillow/
[main]         Complete output (174 lines):
[main]         running install
[main]         running build
[main]         running build_py
[main]         creating build
[main]         creating build/lib.linux-aarch64-3.6
[main]         creating build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GifImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/WalImageFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PalmImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/FliImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/BlpImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageFilter.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/features.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/EpsImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageDraw2.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ExifTags.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PixarImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PcxImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/WebPImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/TiffImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/MpegImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageTk.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PcdImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/SunImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageChops.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageFont.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/IcoImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/DdsImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageOps.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/FtexImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/IptcImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GimpGradientFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageQt.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/MspImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/_version.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/MpoImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/BdfFontFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageMath.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/_util.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImagePath.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageEnhance.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PdfParser.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GbrImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageGrab.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/BmpImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/JpegImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/_tkinter_finder.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageShow.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PpmImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageMode.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageMorph.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageStat.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/TarIO.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImagePalette.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageCms.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/SgiImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/TgaImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PyAccess.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PSDraw.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/TiffTags.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageWin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/MicImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/JpegPresets.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageTransform.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/_binary.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GdImageFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PngImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/XbmImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PcfFontFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/XpmImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/__main__.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/Image.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageDraw.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/DcxImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/WmfImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/CurImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PaletteFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageSequence.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImageColor.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GimpPaletteFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ImtImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PdfImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/FontFile.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/FpxImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/__init__.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/ContainerIO.py -> build/lib.linux-aarch64-3.6/PIL
[main]         copying src/PIL/PsdImagePlugin.py -> build/lib.linux-aarch64-3.6/PIL
[main]         running egg_info
[main]         writing src/Pillow.egg-info/PKG-INFO
[main]         writing dependency_links to src/Pillow.egg-info/dependency_links.txt
[main]         writing top-level names to src/Pillow.egg-info/top_level.txt
[main]         reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
[main]         reading manifest template 'MANIFEST.in'
[main]         warning: no files found matching '*.c'
[main]         warning: no files found matching '*.h'
[main]         warning: no files found matching '*.sh'
[main]         warning: no previously-included files found matching '.appveyor.yml'
[main]         warning: no previously-included files found matching '.coveragerc'
[main]         warning: no previously-included files found matching '.editorconfig'
[main]         warning: no previously-included files found matching '.readthedocs.yml'
[main]         warning: no previously-included files found matching 'azure-pipelines.yml'
[main]         warning: no previously-included files found matching 'codecov.yml'
[main]         warning: no previously-included files matching '.git*' found anywhere in distribution
[main]         warning: no previously-included files matching '*.pyc' found anywhere in distribution
[main]         warning: no previously-included files matching '*.so' found anywhere in distribution
[main]         no previously-included directories found matching '.azure-pipelines'
[main]         no previously-included directories found matching '.ci'
[main]         writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
[main]         running build_ext
[main]         The headers or library files could not be found for zlib,
[main]         a required dependency when compiling Pillow from source.
[main]         Please see the install instructions at:
[main]            https://pillow.readthedocs.io/en/latest/installation.html
[main]         Traceback (most recent call last):
[main]           File "/tmp/pip-install-6weg3wc5/Pillow/setup.py", line 899, in <module>
[main]             zip_safe=not (debug_build() or PLATFORM_MINGW),
[main]           File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
[main]             return distutils.core.setup(**attrs)
[main]           File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
[main]             dist.run_commands()
[main]           File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
[main]             self.run_command(cmd)
[main]           File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
[main]             cmd_obj.run()
[main]           File "/usr/local/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
[main]             return orig.install.run(self)
[main]           File "/usr/local/lib/python3.6/distutils/command/install.py", line 545, in run
[main]             self.run_command('build')
[main]           File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
[main]             self.distribution.run_command(command)
[main]           File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
[main]             cmd_obj.run()
[main]           File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
[main]             self.run_command(cmd_name)
[main]           File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
[main]             self.distribution.run_command(command)
[main]           File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
[main]             cmd_obj.run()
[main]           File "/usr/local/lib/python3.6/distutils/command/build_ext.py", line 339, in run
[main]             self.build_extensions()
[main]           File "/tmp/pip-install-6weg3wc5/Pillow/setup.py", line 694, in build_extensions
[main]             raise RequiredDependencyException(f)
[main]         __main__.RequiredDependencyException: zlib
[main]         During handling of the above exception, another exception occurred:
[main]         Traceback (most recent call last):
[main]           File "<string>", line 1, in <module>
[main]           File "/tmp/pip-install-6weg3wc5/Pillow/setup.py", line 914, in <module>
[main]             raise RequiredDependencyException(msg)
[main]         __main__.RequiredDependencyException:
[main]         The headers or library files could not be found for zlib,
[main]         a required dependency when compiling Pillow from source.
[main]         Please see the install instructions at:
[main]            https://pillow.readthedocs.io/en/latest/installation.html
[main]         ----------------------------------------
[main]
[main]     ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6weg3wc5/Pillow/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6weg3wc5/Pillow/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-y5r7101v/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/Pillow Check the logs for full command output.
[main]

Pygobject

[main]     Step 5/12 : RUN sudo pip3 install pygobject>=3.22.0
[main]      ---> Running in 100906380e47
[main]       ERROR: Command errored out with exit status 1:
[main]        command: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-fynydzr6/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo
[main]            cwd: None
[main]       Complete output (28 lines):
[main]       Collecting setuptools
[main]         Downloading setuptools-47.3.1-py3-none-any.whl (582 kB)
[main]       Collecting wheel
[main]         Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
[main]       Collecting pycairo
[main]         Downloading pycairo-1.19.1.tar.gz (205 kB)
[main]       Using legacy setup.py install for pycairo, since package 'wheel' is not installed.
[main]       Installing collected packages: setuptools, wheel, pycairo
[main]           Running setup.py install for pycairo: started
[main]           Running setup.py install for pycairo: finished with status 'error'
[main]           ERROR: Command errored out with exit status 1:
[main]            command: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b2fj2vcu/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b2fj2vcu/pycairo/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-zvg9fneu/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-fynydzr6/overlay --compile --install-headers /tmp/pip-build-env-fynydzr6/overlay/include/python3.6m/pycairo
[main]                cwd: /tmp/pip-install-b2fj2vcu/pycairo/
[main]           Complete output (12 lines):
[main]           running install
[main]           running build
[main]           running build_py
[main]           creating build
[main]           creating build/lib.linux-aarch64-3.6
[main]           creating build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/__init__.py -> build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/__init__.pyi -> build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/py.typed -> build/lib.linux-aarch64-3.6/cairo
[main]           running build_ext
[main]           'pkg-config' not found.
[main]           Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']
[main]           ----------------------------------------
[main]       ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b2fj2vcu/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b2fj2vcu/pycairo/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-zvg9fneu/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-fynydzr6/overlay --compile --install-headers /tmp/pip-build-env-fynydzr6/overlay/include/python3.6m/pycairo Check the logs for full command output.
[main]       ----------------------------------------
[main]     ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-fynydzr6/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo Check the logs for full command output.
[main]
[main]     The command '/bin/sh -c sudo pip3 install pygobject>=3.22.0' returned a non-zero code: 1

I also tried RUN sudo apt-get install python3-edgetpu, but it still wasn’t found. Again, any help would be appreciated.

There exists two similar base images: balenalib/coral-dev-python:3.6-stretch-run and balenalib/coral-dev-python:3.6-stretch-build. The different is that the former (the one you’re using) does not ship with some common build tools. That is the reason why pip install is erroing out (missing zlib headers, missing pkg-config). The easiest solution is just to use the -build variant, although the final image will be larger.

You can see in our docs more details about base images.

Thank you! by switching to build I was able to install pillow, but still not pygobject or edgetpu.

Hi,

Can you please share with us the error you had when installing pygobject or edgetpu?

Edgetpu

[main]      ---> a698054ef371
[main]     Step 7/11 : RUN sudo apt-get install python3-edgetpu
[main]      ---> Running in 806a1173eb12
[main]     Reading package lists...
[main]     Building dependency tree...
[main]     Reading state information...
[main]     E: Unable to locate package python3-edgetpu
[main]
[main]     The command '/bin/sh -c sudo apt-get install python3-edgetpu' returned a non-zero code: 100

Pygojbect

[main]     Step 6/12 : RUN sudo pip3 install pygobject
[main]      ---> Running in f5b151402409
[main]     Collecting pygobject
[main]       Downloading PyGObject-3.36.1.tar.gz (716 kB)
[main]       Installing build dependencies: started
[main]       Installing build dependencies: finished with status 'error'
[main]       ERROR: Command errored out with exit status 1:
[main]        command: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-h7829022/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo
[main]            cwd: None
[main]       Complete output (31 lines):
[main]       Collecting setuptools
[main]         Downloading setuptools-47.3.1-py3-none-any.whl (582 kB)
[main]       Collecting wheel
[main]         Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
[main]       Collecting pycairo
[main]         Downloading pycairo-1.19.1.tar.gz (205 kB)
[main]       Using legacy setup.py install for pycairo, since package 'wheel' is not installed.
[main]       Installing collected packages: setuptools, wheel, pycairo
[main]           Running setup.py install for pycairo: started
[main]           Running setup.py install for pycairo: finished with status 'error'
[main]           ERROR: Command errored out with exit status 1:
[main]            command: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-an1gfszz/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-an1gfszz/pycairo/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-js3brv4z/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-h7829022/overlay --compile --install-headers /tmp/pip-build-env-h7829022/overlay/include/python3.6m/pycairo
[main]                cwd: /tmp/pip-install-an1gfszz/pycairo/
[main]           Complete output (15 lines):
[main]           running install
[main]           running build
[main]           running build_py
[main]           creating build
[main]           creating build/lib.linux-aarch64-3.6
[main]           creating build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/__init__.py -> build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/__init__.pyi -> build/lib.linux-aarch64-3.6/cairo
[main]           copying cairo/py.typed -> build/lib.linux-aarch64-3.6/cairo
[main]           running build_ext
[main]           Package cairo was not found in the pkg-config search path.
[main]           Perhaps you should add the directory containing `cairo.pc'
[main]           to the PKG_CONFIG_PATH environment variable
[main]           No package 'cairo' found
[main]           Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1.
[main]           ----------------------------------------
[main]       ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-an1gfszz/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-an1gfszz/pycairo/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-js3brv4z/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-h7829022/overlay --compile --install-headers /tmp/pip-build-env-h7829022/overlay/include/python3.6m/pycairo Check the logs for full command output.
[main]       ----------------------------------------
[main]
[main]     ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-h7829022/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo Check the logs for full command output.
[main]
[main]     The command '/bin/sh -c sudo pip3 install pygobject' returned a non-zero code: 1

Hi there,

I tried to user your dockerfile from above, but made sure I used the build variant of the base image, and solved your second problem: installing pygobject. To do this I had to install a few extra dependencies. Here is my dockerfile so far:

FROM balenalib/coral-dev-python:3-stretch-build

# Set our working directory
WORKDIR /usr/src/app

RUN install_packages libcairo2-dev libgirepository1.0-dev

RUN pip3 install --upgrade pip
RUN sudo pip3 install numpy
RUN sudo pip3 install Pillow>=4.0.0
RUN pip3 install wheel
RUN pip3 install pycairo
RUN sudo pip3 install pygobject>=3.22.0
RUN sudo pip3 install protobuf>=3.0.0
RUN sudo pip3 install python3-edgetpu
RUN sudo pip3 install littleutils
RUN sudo pip3 install requests

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.
ENV UDEV=1

CMD ["python3","-m","main.py"]

These are the additions I’ve made to your file:

RUN install_packages libcairo2-dev libgirepository1.0-dev

RUN pip3 install wheel
RUN pip3 install pycairo

I’ll keep looking into the python3-edgetpu issue - but I can see that lots of people on various forums have run into the same issue - so I don’t think it is balena-specific. I can’t promise we’ll be able to fix that in our support shifts, but we’ll try.

Phil

Hi again,

I think I’ve solved the python3-edgetpu issue. I’ve changed the base image to a Debian image, and found that the python3-edgetpu should be installed using apt-get after adding the Google source. Here’s my Dockerfile:

FROM balenalib/coral-dev-debian-python:3-stretch-build

# Set our working directory
WORKDIR /usr/src/app

RUN install_packages libcairo2-dev libgirepository1.0-dev

RUN pip3 install --upgrade pip
RUN sudo pip3 install numpy
RUN sudo pip3 install Pillow>=4.0.0
RUN pip3 install wheel
RUN pip3 install pycairo
RUN sudo pip3 install pygobject>=3.22.0
RUN sudo pip3 install protobuf>=3.0.0

RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get update
RUN install_packages libedgetpu1-std
RUN install_packages python3-edgetpu

RUN sudo pip3 install littleutils
RUN sudo pip3 install requests

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.
ENV UDEV=1

CMD ["python3","-m","main.py"]

Unfortunately I don’t have a Google Coral board to play with (balena should totally buy me one, right?!?) so I can only confirm that I got that Dockerfile to build. I have no idea if it will run. At least you can now do the fun part.

Phil

This worked! Thank you so much for the help, I really appreciate it!