简体   繁体   English

如何导入第 3 方 python 库以用于胶水 python shell 脚本

[英]How to import 3rd party python libraries for use with glue python shell script

I'm trying to import a 3rd party library (datadog) for use with a glue shell script and I'm running into issues.我正在尝试导入第 3 方库 (datadog) 以与胶水 shell 脚本一起使用,但我遇到了问题。 I've packaged the file as a.egg and given the path to it in the glue job, as instructed here .我已将文件打包为 a.egg,并按照此处的说明在胶水作业中给出了它的路径。 This ends up throwing an error saying zipimport.ZipImportError: not a Zip file: '/tmp/glue-python-libs/datadog.egg'.这最终会抛出一个错误,提示 zipimport.ZipImportError: not a Zip file: '/tmp/glue-python-libs/datadog.egg'。 When I try using a zip file instead, it throws ModuleNotFoundError: No module named 'datadog'.当我尝试改用 zip 文件时,它会抛出 ModuleNotFoundError:没有名为“datadog”的模块。 How do I go about importing the library?我go关于导入库怎么办?

As shown in the documentation in your link , WHL files are also supported.链接中的文档所示,还支持 WHL 文件。 It says:它说:

You might already have one or more Python libraries packaged as an.egg or a.whl file.您可能已经将一个或多个 Python 库打包为 .egg 或 .whl 文件。

There is a.whl file available for the DataDog python library here: https://pypi.org/project/datadog/#files .这里有一个可用于 DataDog python 库的 .whl 文件: https://pypi.org/project/datadog/#files You might try downloading that file, uploading it to your S3 bucket, and using that as your Python library for your Glue job.您可以尝试下载该文件,将其上传到您的 S3 存储桶,然后将其用作您的 Glue 作业的 Python 库。 You might be more successful using that than trying to build your own.egg file.使用它可能比尝试构建自己的 .egg 文件更成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用来自第 3 方 API 的 python 将多个文档写入 Firestore - Write Multiple Documents to Firestore using python from 3rd party API 如何从 AWS Glue Python Shell 连接到 RDS 实例? - How to Connect to RDS Instance from AWS Glue Python Shell? 如何使用 ctypes.util.find_library 导入 AWS lambda(python)中的 so 库? - How to use ctypes.util.find_library to import .so libraries in AWS lambda (python)? 如何在重定向到第 3 方云页面的 AWS Route 53 中添加记录? - How to add record in AWS Route 53 that redirects to 3rd party cloud page? 从第 3 方 API 收集数据时如何更新 Firestore 文档而不是创建新文档 - How to update Firestore document when data changes when collected from 3rd Party API instead of creating new document 如何获取 GCP 服务帐户 SignedJWT,以便我可以调用接受 GCP 身份验证的第 3 方服务 - How to Get GCP Service Account SignedJWT so I can call a 3rd party service that accepts GCP auth 如何在 Twilio 上拒绝第三台设备上的呼叫 - How to reject a call on a 3rd device on Twilio 使用 3rd 方 VPN 连接到私有 GKE 集群 - Connecting to Private GKE cluster using 3rd party VPN 在使用 firebase 存储的 GCP 中运行 python 脚本 - Run python script in GCP that use firebase storage 如何为 AWS 胶水工作使用额外的文件 - How to use extra files for AWS glue job
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM