Botocore Error with Heroku: botocore.exceptions.NoCredentialsError: Unable to locate credentials
Botocore Error with Heroku: botocore.exceptions.NoCredentialsError: Unable to locate credentials
我在 Heroku 上部署了 Python Flask 网络应用程序,一切正常,除了我尝试将文件上传到 Amazon S3 Bucket 时。
我尝试在 Heroku 网站和终端中手动将 S3 密钥设置为 Config Vars,但无济于事。
2019-07-17T19:23:49.720789+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
2019-07-17T19:23:49.720791+00:00 app[web.1]: return self._make_api_call(operation_name, kwargs)
2019-07-17T19:23:49.720793+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 648, in _make_api_call
2019-07-17T19:23:49.720795+00:00 app[web.1]: operation_model, request_dict, request_context)
2019-07-17T19:23:49.720797+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 667, in _make_request
2019-07-17T19:23:49.720799+00:00 app[web.1]: return self._endpoint.make_request(operation_model, request_dict)
2019-07-17T19:23:49.720801+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 102, in make_request
2019-07-17T19:23:49.720803+00:00 app[web.1]: return self._send_request(request_dict, operation_model)
2019-07-17T19:23:49.720805+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 132, in _send_request
2019-07-17T19:23:49.720807+00:00 app[web.1]: request = self.create_request(request_dict, operation_model)
2019-07-17T19:23:49.720809+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 116, in create_request
2019-07-17T19:23:49.720811+00:00 app[web.1]: operation_name=operation_model.name)
2019-07-17T19:23:49.720813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
2019-07-17T19:23:49.720815+00:00 app[web.1]: return self._emitter.emit(aliased_event_name, **kwargs)
2019-07-17T19:23:49.720817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
2019-07-17T19:23:49.720819+00:00 app[web.1]: return self._emit(event_name, kwargs)
2019-07-17T19:23:49.720821+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
2019-07-17T19:23:49.720823+00:00 app[web.1]: response = handler(**kwargs)
2019-07-17T19:23:49.720825+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/signers.py", line 90, in handler
2019-07-17T19:23:49.720827+00:00 app[web.1]: return self.sign(operation_name, request)
2019-07-17T19:23:49.720829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/signers.py", line 157, in sign
2019-07-17T19:23:49.720832+00:00 app[web.1]: auth.add_auth(request)
2019-07-17T19:23:49.720834+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/auth.py", line 425, in add_auth
2019-07-17T19:23:49.720836+00:00 app[web.1]: super(S3SigV4Auth, self).add_auth(request)
2019-07-17T19:23:49.720838+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/auth.py", line 357, in add_auth
2019-07-17T19:23:49.720840+00:00 app[web.1]: raise NoCredentialsError
2019-07-17T19:23:49.720847+00:00 app[web.1]: botocore.exceptions.NoCredentialsError: Unable to locate credentials
错误是 "botocore.exceptions.NoCredentialsError: Unable to locate credentials" 即使我在我的 Flask 应用程序中正确设置了 S3 密钥(它在本地主机上工作得很好)。
提前致谢!
对于遇到同样问题的人,我想通了。因此,我最初在我的代码和 Heroku 上的 Settings
中使用我自己的变量名称设置了我的 S3 存储桶的凭据,而不是 AWS_ACCESS_KEY_ID
和 AWS_SECRET_ACCESS_KEY
等看似标准的名称。它有点受限,但为了使凭据正常工作,您必须准确命名它们 AWS_ACCESS_KEY_ID
和 AWS_SECRET_ACCESS_KEY
.
我在 Heroku 上部署了 Python Flask 网络应用程序,一切正常,除了我尝试将文件上传到 Amazon S3 Bucket 时。
我尝试在 Heroku 网站和终端中手动将 S3 密钥设置为 Config Vars,但无济于事。
2019-07-17T19:23:49.720789+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
2019-07-17T19:23:49.720791+00:00 app[web.1]: return self._make_api_call(operation_name, kwargs)
2019-07-17T19:23:49.720793+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 648, in _make_api_call
2019-07-17T19:23:49.720795+00:00 app[web.1]: operation_model, request_dict, request_context)
2019-07-17T19:23:49.720797+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/client.py", line 667, in _make_request
2019-07-17T19:23:49.720799+00:00 app[web.1]: return self._endpoint.make_request(operation_model, request_dict)
2019-07-17T19:23:49.720801+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 102, in make_request
2019-07-17T19:23:49.720803+00:00 app[web.1]: return self._send_request(request_dict, operation_model)
2019-07-17T19:23:49.720805+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 132, in _send_request
2019-07-17T19:23:49.720807+00:00 app[web.1]: request = self.create_request(request_dict, operation_model)
2019-07-17T19:23:49.720809+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/endpoint.py", line 116, in create_request
2019-07-17T19:23:49.720811+00:00 app[web.1]: operation_name=operation_model.name)
2019-07-17T19:23:49.720813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
2019-07-17T19:23:49.720815+00:00 app[web.1]: return self._emitter.emit(aliased_event_name, **kwargs)
2019-07-17T19:23:49.720817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
2019-07-17T19:23:49.720819+00:00 app[web.1]: return self._emit(event_name, kwargs)
2019-07-17T19:23:49.720821+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
2019-07-17T19:23:49.720823+00:00 app[web.1]: response = handler(**kwargs)
2019-07-17T19:23:49.720825+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/signers.py", line 90, in handler
2019-07-17T19:23:49.720827+00:00 app[web.1]: return self.sign(operation_name, request)
2019-07-17T19:23:49.720829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/signers.py", line 157, in sign
2019-07-17T19:23:49.720832+00:00 app[web.1]: auth.add_auth(request)
2019-07-17T19:23:49.720834+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/auth.py", line 425, in add_auth
2019-07-17T19:23:49.720836+00:00 app[web.1]: super(S3SigV4Auth, self).add_auth(request)
2019-07-17T19:23:49.720838+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/botocore/auth.py", line 357, in add_auth
2019-07-17T19:23:49.720840+00:00 app[web.1]: raise NoCredentialsError
2019-07-17T19:23:49.720847+00:00 app[web.1]: botocore.exceptions.NoCredentialsError: Unable to locate credentials
错误是 "botocore.exceptions.NoCredentialsError: Unable to locate credentials" 即使我在我的 Flask 应用程序中正确设置了 S3 密钥(它在本地主机上工作得很好)。
提前致谢!
对于遇到同样问题的人,我想通了。因此,我最初在我的代码和 Heroku 上的 Settings
中使用我自己的变量名称设置了我的 S3 存储桶的凭据,而不是 AWS_ACCESS_KEY_ID
和 AWS_SECRET_ACCESS_KEY
等看似标准的名称。它有点受限,但为了使凭据正常工作,您必须准确命名它们 AWS_ACCESS_KEY_ID
和 AWS_SECRET_ACCESS_KEY
.