导入错误:AWS Glue job脚本Python中没有模块

2024-05-15 22:04:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图提供我的自定义python代码,它需要AWS(pandas)不支持的库。所以,我创建了一个包含必要库的zip文件,并将其上传到S3 bucket。在运行作业时,我在高级属性中指出了S3 bucket的路径,但是我的作业没有成功运行。有人能提出原因吗? 1.我必须在zip文件中包含我的代码吗? 如果是,那么Glue如何理解这是代码? 2。我还需要创建一个包还是只需要zip文件? 感谢您的帮助!


Tags: 文件代码路径awspandas属性s3bucket
3条回答

According to AWS Glue Documentation:

Only pure Python libraries can be used. Libraries that rely on C extensions, such as the pandas Python Data Analysis Library, are not yet supported.

我认为即使我们将python库作为zip文件上传,如果您使用的库依赖于C扩展,它也不会工作。我曾尝试过使用Pandas、Holidays等,就像您尝试过的那样,在联系AWS支持人员时,他们提到它在他们的待办事项列表中(支持这些python libaries),但到目前为止还没有ETA。

因此,任何不是本机python的库,此时都不能在AWS Glue中工作。但应该会在不久的将来推出,因为这是一个流行的需求。

如果你还想试试,请refer to this link,在那里它解释了如何将外部库打包到AWS glue中运行,我试过了,但没有为我工作。

正如Yuva的回答所提到的,我相信目前不可能导入一个不完全用Python编写的库,文档也反映了这一点。

但是,如果有人来这里寻找关于如何在AWS Glue中导入python库的答案,那么这篇文章对如何使用pg8000库有一个很好的解释: AWS Glue - Truncate destination postgres table prior to insert

2019年1月22日发布的AWS胶水作业更新。

在AWS Glue中引入Python Shell作业——发布时间:2019年1月22日

Python shell jobs in AWS Glue support scripts that are compatible with Python 2.7 and come pre-loaded with libraries such as the Boto3, NumPy, SciPy, pandas, and others. You can run Python shell jobs using 1 DPU (Data Processing Unit) or 0.0625 DPU (which is 1/16 DPU). A single DPU provides processing capacity that consists of 4 vCPUs of compute and 16 GB of memory.

更多信息请访问:https://aws.amazon.com/about-aws/whats-new/2019/01/introducing-python-shell-jobs-in-aws-glue/

https://docs.aws.amazon.com/glue/latest/dg/add-job-python.html

相关问题 更多 >