Search code examples
python-3.xpyinstallercx-freezeapscheduler

Python APScheduler keyerror


I have created a .exe file for a .py file with cx_Freeze and pyinstaller, and when im running that file, cmd is generating error:

File "site-packages\apscheduler\schedulers\base.py", line 893, in _create_plugin_instance
KeyError: 'interval'

i have defined a apscheduler job as:

@sched.scheduled_job('interval', seconds=120)

I dont know how to handle this error, when im running my .py file there is no error generated. Any help is appreciated.


Solution

  • cx_Freeze and PyInstaller both omit metadata vital to APScheduler from the packed .exe file. For this reason, setuptools entry points do not work. The workaround:

    from apscheduler.triggers.interval import IntervalTrigger
    
    @sched.scheduled_job(IntervalTrigger(seconds=120))