No trigger by the name “interval” was found

好久不见. 提交于 2019-11-29 15:40:11

This issue is caused by an old version of setuptools. See https://bitbucket.org/agronholm/apscheduler/issues/77/lookuperror-no-trigger-by-the-name

You can solve this by running sudo pip install --upgrade setuptools and reinstallation of apscheduler with sudo pip install --ignore-installed apscheduler

I was working in ipython on a different server. I tried uninstalling/upgrading setuptools and APScheduler. Then I copy and pasted the exact same code I already had into a new notebook that I created on the second server.

And it worked.

if you use virtualenv 1.11.6 as I do, upgrade it to 12.0.7 should fix this problem. according to this thread https://bitbucket.org/agronholm/apscheduler/issue/77/lookuperror-no-trigger-by-the-name you may need to upgrade your setuptools too.

I experienced the problem with the frozen environment by PyInstaller and cx_Freeze, and Flask, although there is no problem with the virtual one. My configuration and the code as follow,

Python 3.6.7 64bit
APScheduler          3.5.3
Flask-APScheduler    1.11.0
Flask                1.0.2
dash                 0.32.2
cx-Freeze            5.1.1
PyInstaller          3.4

# The code produces the error
scheduler = APScheduler()
@scheduler.task('interval', id='do_job_1', seconds=30, misfire_grace_time=900)
def job1():
print('Job 1 executed')

After the code fixed as follow, the problem disappeared,

from apscheduler.triggers.interval import IntervalTrigger
scheduler = APScheduler()
@scheduler.task(IntervalTrigger(seconds=30), id='do_job_1', misfire_grace_time=900)
def job1():
    server.logger.info('Job 1 executed')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!