Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

python - No trigger by the name "interval" was found

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...