AWS Glue Python-Shell:如何提供您自己的库?

时间:2019-08-14 20:09:28

标签: python aws-glue pymssql

我想将aws胶python-shell作业连接到MS SQL Server。我了解我应该使用pymssql库。在我的计算机上,我可以使用脚本,但是对于AWS,我知道我需要将pymssql库上传到S3并进行引用。

如果我想连接到redshift,我正在遵循their example上如何提供自己的egg文件,但是在创建egg文件并运行脚本之后,出现此错误

associatedtype

有人可以提供我自己的图书馆吗?在redshift或ms sql中。只是寻找一个我可以改编和工作的例子。

完整作业日志

Couldn't find index page for 'redshift-module' (maybe misspelled?)

完全错误输出

Creating /glue/lib/installation/site.py
Processing redshift_module-0.1-py3.7.egg
Copying redshift_module-0.1-py3.7.egg to /glue/lib/installation
Adding redshift-module 0.1 to easy-install.pth file

Installed /glue/lib/installation/redshift_module-0.1-py3.7.egg
Processing dependencies for redshift-module==0.1
Searching for redshift-module==0.1
Reading https://pypi.org/simple/redshift-module/
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/

2 个答案:

答案 0 :(得分:0)

提到答案here

在坚果壳中,AWS Glue uses Python 3.6使用的是python 3.7构建的鸡蛋“ redshift_module-0.1-py3.7.egg”

您可能还需要查看documentation,其中包含一些有用的打包选项,例如install_requires=['package']

答案 1 :(得分:0)

我在执行粘合作业中的基本测试时遇到了同样的问题,在进一步调查该场景时,我注意到 Glue Python shell 3 仅使用 Python 3.6。注意:使用不同版本的python创建的egg文件不会相互支持我在这个问题中观察到的。

要省略这一点,您需要制作一个与任何版本兼容的轮文件。

  1. 在 setup.py 文件所在的目录中运行以下命令: $ python3 setup.py bdist_wheel

  2. 将wheel文件上传到S3存储桶

  3. 转到 AWS 胶水作业控制台并创建新作业,提供所有必需的参数并将类型更改为“Python Shell”,并在“Python 库路径”中提供您的 s3 路径(wheel 文件所在的位置)