No trigger by the name "interval" was found
Asked Answered
R

6

6

I've been working with APScheduler and when attempting to run the code I get the error "No trigger by the name 'interval' was found"

It was perfectly on my local machine but will work on my cloud machine.

I have tried: reinstalling apscheduler via pip, easy_install, and manually; upgrading setuptools; upgrading all dependencies.

Edit: Code

if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.add_job(SMS, 'interval', minutes=1)
    scheduler.start()
    print Run Complete

    try:
        # This is here to simulate application activity (which keeps the main thread alive).
        while True:
            time.sleep(2)
    except (KeyboardInterrupt, SystemExit):
        scheduler.shutdown()  # Not strictly necessary if daemonic mode is enabled but should be done if possible


LookupError                               Traceback (most recent call last)
<ipython-input-40-2895cd586d3f> in <module>()
      1 if __name__ == '__main__':
      2     scheduler = BlockingScheduler()
----> 3     scheduler.add_job(SMS, 'interval', hours=1)
      4     scheduler.start()
      5     print "Run Complete"

/Users/admin/anaconda/lib/python2.7/site-packages/apscheduler/schedulers/base.pyc in add_job(self, func, trigger, args, kwargs, id, name, misfire_grace_time, coalesce, max_instances, next_run_time, jobstore, executor, replace_existing, **trigger_args)
    328 
    329         job_kwargs = {
--> 330             'trigger': self._create_trigger(trigger, trigger_args),
    331             'executor': executor,
    332             'func': func,

/Users/admin/anaconda/lib/python2.7/site-packages/apscheduler/schedulers/base.pyc in _create_trigger(self, trigger, trigger_args)
    780 
    781         # Instantiate the trigger class
--> 782         return self._create_plugin_instance('trigger', trigger, trigger_args)
    783 
    784     def _create_lock(self):

/Users/admin/anaconda/lib/python2.7/site-packages/apscheduler/schedulers/base.pyc in _create_plugin_instance(self, type_, alias, constructor_kwargs)
    764                     raise TypeError('The {0} entry point does not point to a {0} class'.format(type_))
    765             else:
--> 766                 raise LookupError('No {0} by the name "{1}" was found'.format(type_, alias))
    767 
    768         return plugin_cls(**constructor_kwargs)

LookupError: No trigger by the name "interval" was found
Ropeway answered 23/2, 2015 at 20:22 Comment(4)
Please show the calling code that gives this error or we can't help you.Goosander
Uhh, try again. For one, I can't even read that, as I'm sure many others can't. For another, by site rules you are not supposed to post pictures of code. Please find a way to include the code in your question.Goosander
Well, have you created a trigger called 'interval' on the cloud machine?Tryout
Peter - it should be included in the apscheduler library (as it is every time I run it on local)Ropeway
R
2

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.

Ropeway answered 24/2, 2015 at 15:28 Comment(0)
E
5

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

Ethology answered 28/10, 2015 at 16:5 Comment(0)
R
3

The other answers point to environmental causes, but it might also be how you're using APScheudler.

Otherwise, verify that the APScheduler class (scheduler/trigger/jobstore/job) is instantiated correctly

  • If this is the case, the LookupError is likely thrown by the BaseScheduler as it tries to access the scheduler's triggers, jobstores, and executors. As of version 3.6.3, that's in the _create_plugin_instance() method of base.py

It'd also be good to verify that your file doesn't use the same name as the APScheduler library

Rubberize answered 31/1, 2020 at 16:39 Comment(0)
R
2

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.

Ropeway answered 24/2, 2015 at 15:28 Comment(0)
P
2

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')
Proton answered 27/12, 2018 at 1:31 Comment(0)
T
2

I had a very similar problem.

My code NOT working:

from apscheduler.schedulers.background import BackgroundScheduler

def job1():
    print("Job 1 fired")


scheduler = BackgroundScheduler()
scheduler.add_job(job1, 'interval', seconds=2, id="job1")
scheduler.start()

This is how I fixed it:

from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger

def job1():
    print("Job 1 fired")

scheduler = BackgroundScheduler()
scheduler.add_job(job1, IntervalTrigger(), seconds=2, id="job1")
scheduler.start()

I have no idea about what was causing the problem.

Truong answered 30/6, 2020 at 14:14 Comment(0)
O
0

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.

Ouzo answered 2/3, 2015 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.