【问题标题】:AWS LAMBDA "errorMessage": "[Errno 30] Read-only file system: 'drive-python-quickstart.json'"AWS LAMBDA "errorMessage": "[Errno 30] 只读文件系统:'drive-python-quickstart.json'"
【发布时间】:2018-01-18 10:05:15
【问题描述】:

我在 AWS Lambda 中的 googledrive 凭证有问题,在我在本地机器上调用函数之前部署了我的 .zip 文件后,一切正常,但是在我在 AWS 中部署 zip 大约 30 分钟后我遇到了 lambda 函数错误

  "errorMessage": "[Errno 30] Read-only file system: 'drive-python-quickstart.json'",
"errorType": "OSError",
  "stackTrace": [
    [
      "/var/task/lambda_function.py",
      33,
      "lambda_handler",
      "pageSize=10,fields=\"nextPageToken, files(id, name)\").execute()"
    ],
    [
      "/var/task/oauth2client/_helpers.py",
      133,
      "positional_wrapper",
      "return wrapped(*args, **kwargs)"
    ],
    [
      "/var/task/googleapiclient/http.py",
      835,
      "execute",
      "method=str(self.method), body=self.body, headers=self.headers)"
    ],
    [
      "/var/task/googleapiclient/http.py",
      162,
      "_retry_request",
      "resp, content = http.request(uri, method, *args, **kwargs)"
    ],
    [
      "/var/task/oauth2client/transport.py",
      186,
      "new_request",
      "credentials._refresh(orig_request_method)"
    ],
    [
      "/var/task/oauth2client/client.py",
      761,
      "_refresh",
      "self._do_refresh_request(http)"
    ],
    [
      "/var/task/oauth2client/client.py",
      802,
      "_do_refresh_request",
      "self.store.locked_put(self)"
    ],
    [
      "/var/task/oauth2client/file.py",
      79,
      "locked_put",
      "f = open(self._filename, 'w')"
    ]
  ]
}

在文件 file.py 我有这个代码:

 def locked_put(self, credentials):
    """Write Credentials to file.
    Args:
        credentials: Credentials, the credentials to store.
    Raises:
        IOError if the file is a symbolic link.
    """
    self._create_file_if_needed()
    _helpers.validate_file(self._filename)
    f = open(self._filename, 'w')
    f.write(credentials.to_json())
    f.close()

def locked_delete(self):
    """Delete Credentials file.
    Args:
        credentials: Credentials, the credentials to store.
    """
    os.unlink(self._filename)

我尝试将 f = open(self._filename, 'w') 设置为 'r',但这没有帮助,也许谁知道我该如何解决?请提出建议。

【问题讨论】:

    标签: python amazon-web-services lambda google-drive-api aws-lambda


    【解决方案1】:

    显然您正在尝试写入不允许的文件。 Lambda 目前仅支持将文件写入 /tmp 目录。

    【讨论】:

    • 谢谢,我修好了!
    • 您能否分享一下您是如何修复它的!我现在正面临这个问题 - @Andrej
    • 我只是将所有凭据文件放在 .zip ant set target 到项目目录中。
    • 我也这样做了,将所有文件放入 .zip 并上传到 s3 中,并在 lambda 中使用该 s3 链接。在这种情况下,我得到 "errorType": "IOError", "errorMessage": "[Errno 30] Read-only file system: 'drive-python-quickstart.json'".. 任何解决这个问题的建议!提前致谢
    • 你是怎么修好的?当我在 /tmp 文件夹中创建文件并尝试将其上传到 EC2 时,我仍然收到该错误 - [Errno 30] 只读文件系统:'1587472029.zip'?
    【解决方案2】:

    我遇到了同样的错误 - 添加到@Tom Melo 的答案中,对于仍在询问的其他人。由于错误是试图在\tmp 文件夹中写入允许您这样做的位置。

    【讨论】:

      猜你喜欢
      • 2021-10-26
      • 2020-07-01
      • 2020-05-19
      • 2018-10-05
      • 2019-09-15
      • 2013-06-19
      • 2021-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多