Yun*_*ing 5 python boto3 aws-glue
我需要使用更新的 boto3 包来执行 AWS Glue Python3 shell 作业(Glue 版本:1.0)。我将 S3 中的下面的wheel文件作为外部Python库包含在内:
boto3-1.13.21-py2.py3-none-any.whl
Run Code Online (Sandbox Code Playgroud)
但是,即使我看到以下日志,也会boto3.__version__打印出来:1.9.203
Successfully installed boto3-1.13.21 botocore-1.16.26 docutils-0.15.2 jmespath-0.10.0 python-dateutil-2.8.1 s3transfer-0.3.3 six-1.15.0 urllib3-1.25.10
Run Code Online (Sandbox Code Playgroud)
由于某种原因,Glue Python Shell 作业不允许我用 Wheel 文件覆盖 boto3 软件包版本。有什么办法可以覆盖吗?
小智 0
发生这种情况的原因是 GLue 作业启动时已经导入了 boto3,因此 Python 会忽略 import 语句。您需要删除 Glue 脚本开头导入的包。您需要将以下代码插入到脚本顶部:
import sys
sys.path.insert(0, '/glue/lib/installation')
keys = [k for k in sys.modules.keys() if ('boto3' in k)]
for k in keys:
del sys.modules[k]
import boto3
print(boto3.__version__)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1867 次 |
| 最近记录: |