在AmazonLinux上安装Python包

问题描述 投票:0回答:1

我正在构建AWS Batch作业。

我有python3包,它被构建在一个基于AmazonLinux的docker镜像中。我需要安装boto3、pandas、s3fs和其他几个模块。我在Docker文件中设置了命令来安装这些模块和python3。

我调用了一个入口脚本,它调用了其他src python文件。

我得到的错误是没有名为boto3的模块,作为我的批处理作业的输出。

我猜测问题出在AmazonLinux上,因为它默认使用python2,而python3包没有找到。

我如何在我的docker镜像中安装我的包可以消耗的包?

python amazon-web-services docker amazon-linux aws-batch
1个回答
1
投票

我把一个琐碎的例子放在一起,包括一些pip包的Batch镜像。https:/github.comnathantheinventorsample-batch-image。它的构建和运行没有错误。

这是Docker文件。

FROM amazonlinux:2
RUN yum install -y python3 python3-pip
RUN python3 -m pip install boto3 pandas s3fs
COPY src /code
ENTRYPOINT [ "python3", "/code/main.py" ]

对于它的价值,我建议使用... python:3.8 作为基础镜像,而不是AmazonLinux,因为它已经用pip正确地设置了python环境,你不必担心意外地运行Python 2。

© www.soinside.com 2019 - 2024. All rights reserved.