【问题标题】:Py4JException error while saving file to S3 with Glue使用 Glue 将文件保存到 S3 时出现 Py4JException 错误
【发布时间】:2021-09-01 11:48:58
【问题描述】:

我正在尝试将默认值文件保存到 S3 存储桶,但出现以下错误:

An error occurred while calling o654.__getstate__. Trace:
py4j.Py4JException: Method __getstate__([]) does not exist
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
    at py4j.Gateway.invoke(Gateway.java:274)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:748)

我准备的代码sn-p,好像是py4j相关的问题。 感谢您的建议!

    BUCKET = 'my_bucket'
    s3 = boto3.client('s3')
    keyid = 'xxxxx'

    print("Uploading S3 object with SSE-KMS")
    s3.put_object(Bucket=BUCKET,
              Key='encrypt-key',
              Body=b'foobar',
              ServerSideEncryption='aws:kms',
              # Optional: SSEKMSKeyId
              SSEKMSKeyId=keyid)
    print("Saving to S3, Done")

【问题讨论】:

标签: python amazon-s3 aws-glue py4j


【解决方案1】:

潜在问题是 Key 的语法错误。它应该遵循subfolder/subfolder/file_to_write.txt

/ 必须添加到每个子文件夹(又名键)名称中,否则 AWS 不会将其视为存储桶中的路径。

【讨论】:

    猜你喜欢
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 2021-09-09
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    相关资源
    最近更新 更多