AttributeError: модуль 'dateutil.tz' не имеет атрибута 'UT C' в Zappa Deploy - PullRequest
0 голосов
/ 30 марта 2020

При попытке развернуть мою AWS лямбда-функцию получите эту ошибку на моей Stacktrace

(python-dateutil 2.8.1 (/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages), Requirement.parse('python-dateutil<2.7.0'), {'zappa'})
Calling deploy for stage development..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/cli.py", line 549, in dispatch_command
    self.deploy(self.vargs['zip'])
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/cli.py", line 709, in deploy
    self.zappa.create_iam_roles()
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/core.py", line 2557, in create_iam_roles
    role, credentials_arn = self.get_credentials_arn()
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/zappa/core.py", line 2536, in get_credentials_arn
    self.credentials_arn = role.arn
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/boto3/resources/factory.py", line 339, in property_loader
    self.load()
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/boto3/resources/factory.py", line 505, in do_action
    response = action(self, *args, **kwargs)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/client.py", line 316, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/client.py", line 613, in _make_api_call
    operation_model, request_dict, request_context)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/client.py", line 632, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/endpoint.py", line 135, in _send_request
    request, operation_model, context)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/endpoint.py", line 167, in _get_response
    request, operation_model)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/endpoint.py", line 218, in _do_get_response
    response_dict, operation_model.output_shape)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 242, in parse
    parsed = self._do_parse(response, shape)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 509, in _do_parse
    parsed = self._parse_shape(shape, start)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 302, in _parse_shape
    return handler(shape, node)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 377, in _handle_structure
    member_shape, member_node)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 302, in _parse_shape
    return handler(shape, node)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 377, in _handle_structure
    member_shape, member_node)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 302, in _parse_shape
    return handler(shape, node)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 175, in _get_text_content
    return func(self, shape, text)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/parsers.py", line 462, in _handle_timestamp
    return self._timestamp_parser(text)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/utils.py", line 626, in parse_timestamp
    return _parse_timestamp_with_tzinfo(value, tzinfo)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/botocore/utils.py", line 607, in _parse_timestamp_with_tzinfo
    return dateutil.parser.parse(value, tzinfos={'GMT': tzutc()})
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/dateutil/parser/_parser.py", line 1374, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/dateutil/parser/_parser.py", line 660, in parse
    ret = self._build_tzaware(ret, res, tzinfos)
  File "/Users/supratik/.local/share/virtualenvs/api_sourcer-sM-JSZy3-/Users/supratik/.pyenv/shims/python/lib/python3.6/site-packages/dateutil/parser/_parser.py", line 1201, in _build_tzaware
    aware = naive.replace(tzinfo=tz.UTC)
AttributeError: module 'dateutil.tz' has no attribute 'UTC'

==============``` 

1 Ответ

0 голосов
/ 31 марта 2020

Возникла похожая проблема при попытке скопировать файлы из AWS S3 с помощью aws cli. Запуск pip install python-dateutil обновил python -dateutil до 2.8.1, и теперь он работает хорошо.

...