ImportError: No module named redis

2,815 views
Skip to first unread message

Aqs Younas

unread,
Apr 18, 2014, 2:19:08 PM4/18/14
to redi...@googlegroups.com
When i try to run following ApSchduler example i encounter this error :ImportError: No module named redis

#!/usr/bin/python
"""
This example demonstrates the use of the Redis job store.
On each run, it adds a new alarm that fires after ten seconds.
You can exit the program, restart it and observe that any previous alarms that have not fired yet are still active.
Running the example with the --clear switch will remove any existing alarms.
"""

from datetime import datetime, timedelta
import sys

from apscheduler.scheduler import Scheduler
from apscheduler.jobstores.redis import RedisJobStore


def alarm(time):
    print('Alarm! This alarm was scheduled at %s.' % time)


if __name__ == '__main__':
    scheduler = Scheduler()
    jobstore = RedisJobStore(jobs_key='example.jobs', run_times_key='example.run_times')
    if len(sys.argv) > 1 and sys.argv[1] == '--clear':
        jobstore.remove_all_jobs()

    scheduler.add_jobstore(jobstore)
    alarm_time = datetime.now() + timedelta(seconds=10)
    scheduler.add_job(alarm, 'date', run_date=alarm_time, args=[datetime.now()])
    print('To clear the alarms, run this example with the --clear argument.')
    print('Press Ctrl+C to exit')

    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass

Josiah Carlson

unread,
Apr 18, 2014, 4:09:42 PM4/18/14
to redi...@googlegroups.com
You need to have the Python Redis library installed. If you have pip installed, you should be able to do "sudo pip install redis". Otherwise you can get it here: https://pypi.python.org/pypi/redis

 - Josiah



--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages