我遇到了以下导入错误
"ImportError:没有名为调度程序的模块“
当我运行以下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我已经安装了APS调度程序,使用以下命令: sudo pip install apscheduler
我还使用: sudo pip install apscheduler --upgrade还使用"sudo apt-get install update && sudo apt-get upgrade“升级了我的系统
发布于 2014-07-24 05:33:56
您的导入错误。它应该是:
from apscheduler.schedulers.blocking import BlockingScheduler参考示例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发布于 2014-09-07 20:10:36
我也有同样的问题,但是我发现,
我已经安装了apscheduler版本3,然后我转移到版本2.1.2,使用
pip uninstall apscheduler
pip install apscheduler==2.1.2在切换到2.1.2版本之前,如果你想使用版本3中增加的额外功能,只需结账即可。
https://stackoverflow.com/questions/24921383
复制相似问题