1

I'm using docker-backed lambdas with the AWS-provided base image for python3.8.

It looks like it tries to build matplotlib from scratch, then fails out with gcc related errors.

The repro is straightforward, just try to build the following Dockerfile:

FROM amazon/aws-lambda-python:3.8
RUN yum -y install gcc
RUN pip3 install --upgrade pip
RUN pip3 install matplotlib

Error:

#7 13.82     set build/lib.linux-x86_64-3.8/matplotlib/_version.py to '3.4.3'
#7 13.82     running build_ext
#7 13.82     creating tmp
#7 13.82     gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/var/lang/include/python3.8 -c /tmp/tmpjr1hj4f1.cpp -o tmp/tmpjr1hj4f1.o -fvisibility=hidden
#7 13.82     gcc: error trying to exec 'cc1plus': execvp: No such file or directory
#7 13.82     gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/var/lang/include/python3.8 -c /tmp/tmp74f416b5.cpp -o tmp/tmp74f416b5.o -fvisibility-inlines-hidden
#7 13.82     gcc: error trying to exec 'cc1plus': execvp: No such file or directory
#7 13.82     gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/var/lang/include/python3.8 -c /tmp/tmp19pyjmxw.cpp -o tmp/tmp19pyjmxw.o -flto
#7 13.82     gcc: error trying to exec 'cc1plus': execvp: No such file or directory
#7 13.82     Extracting /project/freetype/freetype2/2.6.1/freetype-2.6.1.tar.gz
#7 13.82     Building freetype in build/freetype-2.6.1
#7 13.82     GNU make (>= 3.80) or makepp (>= 1.19) is required to build FreeType2.
#7 13.82     Please try
#7 13.82     
#7 13.82       MAKE=<GNU make command name> ./configure
#7 13.82     
#7 13.82     or
#7 13.82     
#7 13.82       MAKE="makepp --norc-substitution" ./configure
#7 13.82     Traceback (most recent call last):
#7 13.82       File "<string>", line 1, in <module>
#7 13.82       File "/tmp/pip-install-v3njpp10/matplotlib_5bf0432199ce40b5a487eafc6a513cc3/setup.py", line 258, in <module>
#7 13.82         setup(  # Finally, pass this all along to distutils to do the heavy lifting.
#7 13.82       File "/var/lang/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
#7 13.82         return distutils.core.setup(**attrs)
#7 13.82       File "/var/lang/lib/python3.8/distutils/core.py", line 148, in setup
#7 13.82         dist.run_commands()
#7 13.82       File "/var/lang/lib/python3.8/distutils/dist.py", line 966, in run_commands
#7 13.82         self.run_command(cmd)
#7 13.82       File "/var/lang/lib/python3.8/distutils/dist.py", line 985, in run_command
#7 13.82         cmd_obj.run()
#7 13.82       File "/var/lang/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
#7 13.82         return orig.install.run(self)
#7 13.82       File "/var/lang/lib/python3.8/distutils/command/install.py", line 545, in run
#7 13.82         self.run_command('build')
#7 13.82       File "/var/lang/lib/python3.8/distutils/cmd.py", line 313, in run_command
#7 13.82         self.distribution.run_command(command)
#7 13.82       File "/var/lang/lib/python3.8/distutils/dist.py", line 985, in run_command
#7 13.82         cmd_obj.run()
#7 13.82       File "/var/lang/lib/python3.8/distutils/command/build.py", line 135, in run
#7 13.82         self.run_command(cmd_name)
#7 13.82       File "/var/lang/lib/python3.8/distutils/cmd.py", line 313, in run_command
#7 13.82         self.distribution.run_command(command)
#7 13.82       File "/var/lang/lib/python3.8/distutils/dist.py", line 985, in run_command
#7 13.82         cmd_obj.run()
#7 13.82       File "/var/lang/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
#7 13.82         _build_ext.run(self)
#7 13.82       File "/var/lang/lib/python3.8/distutils/command/build_ext.py", line 340, in run
#7 13.82         self.build_extensions()
#7 13.82       File "/tmp/pip-install-v3njpp10/matplotlib_5bf0432199ce40b5a487eafc6a513cc3/setup.py", line 199, in build_extensions
#7 13.82         package.do_custom_build(env)
#7 13.82       File "/tmp/pip-install-v3njpp10/matplotlib_5bf0432199ce40b5a487eafc6a513cc3/setupext.py", line 596, in do_custom_build
#7 13.82         subprocess.check_call(
#7 13.82       File "/var/lang/lib/python3.8/subprocess.py", line 364, in check_call
#7 13.82         raise CalledProcessError(retcode, cmd)
#7 13.82     subprocess.CalledProcessError: Command '['./configure', '--with-zlib=no', '--with-bzip2=no', '--with-png=no', '--with-harfbuzz=no', '--enable-static', '--disable-shared']' returned non-zero exit status 1.
#7 13.82     ----------------------------------------
#7 13.83 ERROR: Command errored out with exit status 1: /var/lang/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v3njpp10/matplotlib_5bf0432199ce40b5a487eafc6a513cc3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v3njpp10/matplotlib_5bf0432199ce40b5a487eafc6a513cc3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vdv6xdpv/install-record.txt --single-version-externally-managed --compile --install-headers /var/lang/include/python3.8/matplotlib Check the logs for full command output.
ouflak
  • 2,458
  • 10
  • 44
  • 49
alex9311
  • 1,230
  • 1
  • 18
  • 42

6 Answers6

2

It seems like you're getting an error because of missing binaries that are needed to compile matplotlib.

Can you try to install the additional g++ package? It is usualy named gcc-c++ with the yum installer so:

FROM amazon/aws-lambda-python:3.8
RUN yum -y install gcc gcc-c++
RUN pip3 install --upgrade pip
RUN pip3 install matplotlib
stijndepestel
  • 3,076
  • 2
  • 18
  • 22
  • hey thanks for answering, I tried that and got GNU make (>= 3.80) or makepp (>= 1.19) is required to build FreeType2. I'll keep working on it – alex9311 Aug 13 '21 at 16:44
2

I had the same problem and I was trying to install matplotlib in a docker container using an alpine image. For me the fix was the same as it was for @alex9311, but since I am on a docker alpine build, I was adding the following line to my image:

RUN apk update && apk add --no-cache build-base

I hope this helps. Only adding it as an answer so it doesn't get overlooked when it might help.

ouflak
  • 2,458
  • 10
  • 44
  • 49
shadow
  • 151
  • 2
  • 12
1

the fix was to add compiler tools to the docker image before trying to compile matplotlib. I still don't know why this started failing for me, perhaps the base image was updated.

RUN yum -y groups mark install "Development Tools" && yum -y groups mark convert "Development Tools" && yum -y group install "Development Tools"
alex9311
  • 1,230
  • 1
  • 18
  • 42
1

I'm running into the same issue and I think it is matplotlib's fault. They released a new version (3.4.3) 17h ago as of this writing. For me setting the version to the previous minor release, i.e. matplotlib==3.4.2 fixes it.

There were no issues until today with my lambda deployment and nothing in my code changed so I think it's something in the new release though I do not know what exactly.

Daniel
  • 430
  • 1
  • 4
  • 12
  • 1
    glad it's not just me, my fix with installing compiler tools seems to work if you want to use that as a workaround – alex9311 Aug 13 '21 at 22:27
  • For me also version `3.4.2` throws the same error. But I am installing in docker with alpine – shadow Sep 08 '21 at 14:48
1

I was able to fix the problem by installing "make". In the error logs posted in the question there is a statement

GNU make (>= 3.80) or makepp (>= 1.19) is required to build FreeType2.

This is the cause of the matplotlib installation failure. The cause of the error is that the docker image is missing an installation of GNU make. The accepted answer installs all the packages in the "Development Tools" group (which includes make) which is not necessary. It will increase the docker image size which can be avoided by installing only "make".

FROM amazon/aws-lambda-python:3.8
RUN yum -y install gcc gcc-c++ make
RUN pip3 install --upgrade pip
RUN pip3 install matplotlib

The matplotlib installation was successful on installing make before installing matplotlib

Mayur Rao
  • 11
  • 1
0

Changing the version as Daniel suggested also worked for me. matplotlib==3.5.1 in my case worked.

tweak
  • 13
  • 4