Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

721
Views
Python APScheduler fails: 'Only timezones from the pytz library are supported' error

I am trying to run a python async app with an asyncioscheduler scheduled job but the APScheduler fails during build because of this error:

'Only timezones from the pytz library are supported' error

I do include pytz in my app and i am passing the timezone. What is causing the error?

I am calling the asyncioscheduler in a class where i create job manager:

from apscheduler.schedulers.asyncio import AsyncIOScheduler


class ScheduleManager:
    def __init__(self) -> None:
    self.scheduler = AsyncIOScheduler()
    
    def start(self):
    self.scheduler.start()

    def stop(self):
    self.scheduler.shutdown()
    
    def add_seconds_interval_job(self, callback, interval : int):
    self.scheduler.add_job(callback, 'interval', seconds = interval)
    
    def add_minutes_interval_job(self, callback, interval : int):
    self.scheduler.add_job(callback, 'interval', minutes = interval)

    def add_hours_interval_job(self, callback, interval : int):
    self.scheduler.add_job(callback, 'interval', hours = interval)

    def add_days_interval_job(self, callback, interval : int):
    self.scheduler.add_job(callback, 'interval', days = interval)

then i call this manager from my application like :

from jobs import ScheduleManager, ConfigJob

class AppInitializer:

    def __init__(self) -> None:
    self.schedule_manager = ScheduleManager()
    self.config__job = ConfigJob()

    async def initialize(self, app, loop):
    self.schedule_manager.add_seconds_interval_job(self.config_job.run, 5)
    self.schedule_manager.start()
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Ok so it required a dependency tzlocal==2.1 so it could get local timezone, i assume for some reason the version that the module has does not work on my system

over 4 years ago · Santiago Trujillo Report

0

The tzlocal library switched from pytz to zoneinfo timezones in 3.0 and APScheduler 3.x is not compatible with those. Due to this, APScheduler 3.7.0 has tzlocal pinned to v2.x. If you're getting tzlocal 3.0 installed through APScheduler, you're using an old version. Please upgrade.

over 4 years ago · Santiago Trujillo Report

0

I stumbled over this as well. And now there's a new tzlocal version (4.1) out that isn't actually compatible with apscheduler 3.x which isn't handled in the pinning: apscheduler 3.8.1 requires tzlocal!=3.*,>=2.0 This breaks things if you have tzlocal==4.1 installed. I pinned tzlocal now manually in my requirements.yml:

tzlocal<3.0 or more specific tzlocal==2.1

Update: The apscheduler docs state that this issue is fixed with 3.8.1 and with 3.9.0 they don't enforce pytz time zones anymore. After some testing with different versions I nevertheless still get the same errors with Python 3.10.2, apscheduler 3.8.1/3.9.0 and tzlocal 4.0/4.1. I am forced to use tzlocal<3.0.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!