gpt4 book ai didi

python - 未找到名为 "interval"的触发器

转载 作者:太空宇宙 更新时间:2023-11-03 15:09:32 25 4
gpt4 key购买 nike

我一直在使用 APScheduler,在尝试运行代码时出现错误“未找到名称为‘interval’的触发器”

它在我的本地机器上完美运行,但可以在我的云机器上运行。

我尝试过:通过 pip、easy_install 和手动重新安装 apscheduler;升级设置工具;升级所有依赖项。

编辑:代码

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

最佳答案

此问题是由旧版本的设置工具引起的。参见 https://bitbucket.org/agronholm/apscheduler/issues/77/lookuperror-no-trigger-by-the-name

您可以通过运行 sudo pip install --upgrade setuptools 并使用 sudo pip install --ignore-installed apscheduler 重新安装 apscheduler 来解决此问题

关于python - 未找到名为 "interval"的触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28682723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com