APScheduler(Advance Python Scheduler) ImportError: No module named scheduler
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24921383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
APScheduler(Advance Python Scheduler) ImportError: No module named scheduler
提问by arshpreet
I am having following import error
我有以下导入错误
"ImportError: No module named scheduler"
“导入错误:没有名为调度程序的模块”
when I run the following python script:
当我运行以下 python 脚本时:
"""
Demonstrates how to use the blocking scheduler to schedule a job that execute$
"""
from datetime import datetime
import os
from apscheduler.scheduler import BlockingScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'$
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
I have installed APS scheduler using: sudo pip install apscheduler
我已经使用以下命令安装了 APS 调度程序:sudo pip install apscheduler
I have also upgraded using: sudo pip install apscheduler --upgrade Also upgraded my system using "sudo apt-get install update && sudo apt-get upgrade"
我还使用以下方法进行了升级:sudo pip install apscheduler --upgrade 还使用“sudo apt-get install update && sudo apt-get upgrade”升级了我的系统
采纳答案by Mahesh Shitole
I got same issue, but then I found,
我遇到了同样的问题,但后来我发现,
I had installed apscheduler version 3 then I shifted to version 2.1.2 using,
我已经安装了 apscheduler 版本 3,然后我转移到版本 2.1.2 使用,
pip uninstall apscheduler
pip install apscheduler==2.1.2
Just checkout before switching to version 2.1.2, If you wanted to use extra features added in version 3. In my case I didn't wanted much.
在切换到版本 2.1.2 之前只需签出,如果您想使用版本 3 中添加的额外功能。就我而言,我不需要太多。
回答by Gerrat
Your import is wrong. It should be:
你的导入是错误的。它应该是:
from apscheduler.schedulers.blocking import BlockingScheduler
Reference example here:
参考例子在这里:
"""
Demonstrates how to use the blocking scheduler to schedule a job that executes on 3 second
intervals.
"""
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass