1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

apscheduler(Advanced Python Scheduler)を使おうと思った時にwarningがでる。`The zone attribute is specific to pytz's interface; please migrate to a new time zone provider`

Posted at

以下実行時に表題のwarningがでた時の解決策(回避策)

pythonのapschedulerでkeepaliveの練習する

apschedulerについては以下

Advanced Python Scheduler
Advanced Python Scheduler (APScheduler) is a Python library that lets you schedule your Python code to be executed later, either just once or periodically.

warningは以下

`The zone attribute is specific to pytz's interface; please migrate to a new time zone provider`

以下の実装部分がwarning出している様子

https://github.com/agronholm/apscheduler/blob/v3.8.1/apscheduler/util.py#L95
if obj.zone == 'local':

原因は以下のようにapscheduler内で使っているzoneinfoがdeprecatedであるためである様子

PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider
The problem is pytz is considered deprecated in favor of zoneinfo module and its backports. So even if you set directly timezone argument as suggested before, you'll probably face the same warning from some other places until apsheduler would fix pytz usage for modern Python version.

以下の通りtzlocalのバージョンが起因しているようなので、tzlocalのバージョンを更新すると解決した。

https://github.com/agronholm/apscheduler/discussions/570
This happens with tzlocal 4.0. You can either (safely) ignore those warnings or downgrade tzlocal to 2.x. The problem is "properly" fixed on master but likely won't be in the 3.x branch.

pip3 install tzlocal==2.1

ただし、記載の注意点の通り、他の依存関係に影響あるかもしれないので注意

But, please, pay attention it could break other project dependencies, so be careful.

#参考
PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider
Advanced Python Scheduler
https://github.com/agronholm/apscheduler/discussions/570
PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. #187

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?