不了解此pytz AttributeError:'UTC'对象没有属性'utc_timezone'

时间:2019-02-20 01:01:07

标签: python apache airflow utc pytz

问题:

execution_date_to_search_for = pytz.timezone('UTC').utc_timezone.localize(datetime.strptime((process["airflow_execution_date"]).replace("T", " "),'%Y-%m-%d %H:%M:%S.%f'))
[2019-02-20 11:56:42,673] {base_task_runner.py:101} INFO - Job 661: Subtask kill_halted_tasks AttributeError: 'UTC' object has no attribute 'utc_timezone'

该链接包含我用于杀死Airflow上暂停的任务的源代码。我试图更改时间格式,但它总是抛出错误。

https://github.com/teamclairvoyant/airflow-maintenance-dags/blob/master/kill-halted-tasks/airflow-kill-halted-tasks.py

1 个答案:

答案 0 :(得分:0)

应该是:

execution_date_to_search_for = pytz.timezone('UTC').localize(datetime.strptime((process["airflow_execution_date"]).replace("T", " "),'%Y-%m-%d %H:%M:%S.%f'))

也请向维护者提出问题,以解决该问题。