问题描述
我一直在使用APScheduler,当尝试运行代码时,出现错误找不到名为'interval'的触发器"
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.
我尝试过:通过pip,easy_install和手动重新安装apscheduler;升级设置工具;升级所有依赖项.
I have tried: reinstalling apscheduler via pip, easy_install, and manually; upgrading setuptools; upgrading all dependencies.
代码
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
推荐答案
我在其他服务器上的ipython中工作.我尝试卸载/升级setuptools和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.
它奏效了.
这篇关于没有名称"interval"的触发.被找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!