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

Table of Content

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

Error Showing

/py_env/lib/python3.6/site-packages/apscheduler/util.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  if obj.zone == 'local':
Press Ctrl+C to exit
/py_env/lib/python3.6/site-packages/apscheduler/triggers/interval.py:66: PytzUsageWarning: The normalize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  return self.timezone.normalize(next_fire_time)

image

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

Add timezone="Asia/Ho_Chi_Minh" to apscheduler

from apscheduler.schedulers.blocking import BlockingScheduler

if __name__ == '__main__':
    scheduler = BlockingScheduler(timezone="Asia/Ho_Chi_Minh")
    # interval 3 tieng
    scheduler.add_job(rundaily, 'interval', seconds=10800)
    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))

    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass

References

  1. https://stackoverflow.com/questions/69776414/pytzusagewarning-the-zone-attribute-is-specific-to-pytzs-interface-please-mig
  2. https://www.zeitverschiebung.net/en/timezone/asia--ho_chi_minh

Leave a Reply

Your email address will not be published.