不明白这个pytz AttributeError:'UTC'对象没有属性'utc_timezone'

问题描述 投票:0回答:1

问题:

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

python apache airflow utc pytz
1个回答
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'))

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

© www.soinside.com 2019 - 2024. All rights reserved.