【问题标题】:AWS Glue Python-Shell : How to provide your own library?AWS Glue Python-Shell:如何提供自己的库?
【发布时间】:2019-08-14 20:09:28
【问题描述】:

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

如果我想连接到 redshift,我正在关注 their example 如何提供您自己的 egg 文件,但在创建 egg 文件并运行脚本后我收到此错误

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

谁能帮助提供我如何完成提供自己的库?在 redshift 或 ms sql 中。只是寻找一个我可以适应和工作的例子。

完整的作业日志

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/

完整的错误输出

Couldn't find index page for 'redshift-module' (maybe misspelled?)
No local packages or working download links found for redshift-module==0.1
error: Could not find suitable distribution for Requirement.parse('redshift-module==0.1')

【问题讨论】:

  • 你能试试这个stackoverflow.com/questions/46329561/aws-glue-python/…,让我知道它是否适合你吗?
  • 这就是我正在做的。尽管那篇文章是关于 Glue (Apache Spark),但我正在使用 Python-Shell,它们都要求您在作业配置中拥有 S3 中的第三方库。在日志中,我看到它找到了我的 .egg 文件,但没有找到我的库。

标签: python aws-glue pymssql


【解决方案1】:

答案提到here

简而言之,AWS Glue uses Python 3.6 而鸡蛋“redshift_module-0.1-py3.7.egg”是使用 python 3.7 构建的

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

【讨论】:

    【解决方案2】:

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

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

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

      $ python3 setup.py bdist_wheel

    2. 上传wheel文件到S3桶

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

    【讨论】:

      猜你喜欢
      • 2022-08-11
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      相关资源
      最近更新 更多