我将docker支持的lambdas与AWS提供的python3.8基础映像结合使用。
它看起来像是尝试从头开始构建matplotlib,然后因gcc相关错误而失败。
复制过程很简单,只需尝试构建以下Dockerfile:
FROM amazon/aws-lambda-python:3.8
RUN yum -y install gcc
RUN pip3 install --upgrade pip
RUN pip3 install matplotlib
错误:
#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.
6条答案
按热度按时间mbjcgjjk1#
看起来你得到了一个错误,因为缺少编译matplotlib所需的二进制文件。
你可以尝试安装额外的
g++
包吗?它通常被命名为gcc-c++
与yum安装程序,所以:2admgd592#
修复的方法是在编译matplotlib之前添加编译器工具到docker映像。我仍然不知道为什么我开始失败,也许是基础映像被更新了。
0mkxixxg3#
我遇到了同样的问题,我认为这是matplotlib的错。他们在17小时前发布了一个新版本(3.4.3)。对我来说,将版本设置为以前的次要版本,即
matplotlib==3.4.2
修复了它。直到今天,我的lambda部署都没有问题,我的代码也没有任何变化,所以我认为这是新版本中的一些东西,尽管我不知道具体是什么。
bmp9r5qi4#
我遇到了同样的问题,我试图使用alpine映像在docker容器中安装matplotlib。对我来说,修复方法和@alex9311一样,但由于我使用的是docker alpine版本,我在映像中添加了以下行:
RUN apk update && apk add --no-cache build-base
我希望这能有所帮助。只是把它作为一个答案添加进来,这样它就不会在可能有帮助的时候被忽视。
lzfw57am5#
我能够通过安装“make”来修复这个问题。在问题中发布的错误日志中有一个声明
这是matplotlib安装失败的原因。错误的原因是docker映像缺少GNU make的安装。可接受的答案是安装“Development Tools”组中的所有软件包(包括make),这是不必要的。这将增加docker映像的大小,这可以通过只安装“make”来避免。
在安装matplotlib之前安装make时matplotlib安装成功
ogq8wdun6#
将版本更改为Daniel suggested也对我有效。
matplotlib==3.5.1
在我的情况下有效。