ImportError: No module named redis

This is the place for queries that don't fit in any of the other categories.

ImportError: No module named redis

Postby aqsyounas » Fri Apr 18, 2014 6:17 pm

Running this Apscheduler example i got this error :ImportError: No module named redis

Code: Select all
#!/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
Last edited by stranac on Fri Apr 18, 2014 8:03 pm, edited 2 times in total.
Reason: locked, code tags (stranac fixed code tags)
aqsyounas
 
Posts: 7
Joined: Fri Apr 18, 2014 6:14 pm

Re: ImportError: No module named redis

Postby 7stud » Fri Apr 18, 2014 7:44 pm

Code: Select all
from apscheduler.jobstores.redis import RedisJobStore


It's pretty simple: There is no file called redis.py in a directory named apscheduler/jobstores/.
7stud
 
Posts: 106
Joined: Wed Apr 02, 2014 2:36 am

Re: ImportError: No module named redis

Postby aqsyounas » Thu Apr 24, 2014 6:42 pm

Thanks it helped :)
aqsyounas
 
Posts: 7
Joined: Fri Apr 18, 2014 6:14 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 2 guests