在AWS Python 3.9镜像中安装LibreOffice的yum源问题求助
解决方案:在Lambda Python 3.9镜像中安装LibreOffice
你使用的public.ecr.aws/lambda/python:3.9基于CentOS 7,默认yum源未包含LibreOffice,以下两种可行方法可解决该问题:
方法1:通过EPEL源安装
CentOS 7的EPEL源提供了LibreOffice的预编译包,只需先添加EPEL源再执行安装:
修改后的Dockerfile:
FROM public.ecr.aws/lambda/python:3.9 # Install Mono runtime RUN rpm --import https://download.mono-project.com/repo/xamarin.gpg && \ curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo && \ yum install -y mono-complete && yum clean all # 添加EPEL源并安装LibreOffice RUN yum install -y epel-release && \ yum install -y libreoffice && \ yum clean all
方法2:直接安装官方RPM包
如果EPEL源的LibreOffice版本不符合需求,可直接下载官方针对CentOS 7的RPM包进行本地安装:
修改后的Dockerfile:
FROM public.ecr.aws/lambda/python:3.9 # Install Mono runtime RUN rpm --import https://download.mono-project.com/repo/xamarin.gpg && \ curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo && \ yum install -y mono-complete && yum clean all # 安装依赖并下载LibreOffice RPM包安装 RUN yum install -y wget tar && \ # 替换为对应CentOS 7 x86_64架构的LibreOffice稳定版下载链接 wget https://download.documentfoundation.org/libreoffice/stable/[目标版本号]/rpm/x86_64/LibreOffice_[版本号]_Linux_x86-64_rpm.tar.gz && \ tar -xzf LibreOffice_[版本号]_Linux_x86-64_rpm.tar.gz && \ yum localinstall -y LibreOffice_[版本号]_Linux_x86-64_rpm/RPMS/*.rpm && \ rm -rf LibreOffice_[版本号]_Linux_x86-64_rpm.tar.gz LibreOffice_[版本号]_Linux_x86-64_rpm && \ yum remove -y wget tar && \ yum clean all
注意:方法2中需将占位符替换为实际的LibreOffice版本号,确保下载包对应CentOS 7的x86_64架构。
内容的提问来源于stack exchange,提问作者Noam Azoulay
相关产品推荐
相关产品推荐

