簡體   English   中英

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

[英]AWS Glue Python-Shell : How to provide your own library?

我想讓一個 aws 膠水 python-shell 作業連接到 MS SQL Server。 我知道我應該使用 pymssql 庫。 在我的計算機上,我的腳本可以運行,但是使用 AWS 我知道我需要將 pymssql 庫上傳到 S3 並引用它。

如果我想連接到 redshift,我正在遵循 他們關於如何提供自己的 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')

答案在這里提到

簡而言之, AWS Glue 使用 Python 3.6,而雞蛋“redshift_module-0.1-py3.7.egg”是使用 Python 3.7 構建的

您可能還需要查看文檔,其中包含一些有用的打包選項,例如install_requires=['package']

我在粘合作業中執行基本測試時遇到了同樣的問題,在進一步調查我注意到 Glue Python shell 3 僅使用 Python 3.6 的場景時。 注意:使用不同版本的 python 創建的 egg 文件不會相互支持我在這個問題中觀察到的。

要省略這一點,您需要制作一個與任何版本兼容的輪文件。

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

  2. 將車輪文件上傳到 S3 存儲桶

  3. 轉到 AWS 膠水作業控制台並創建新作業,提供所有必需的參數並將類型更改為“Python Shell”,並在“Python 庫路徑”中提供您的 s3 路徑(wheel 文件所在的位置)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM