Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APScheduler - ImportError: No module named 'apscheduler'

I don't know why I get this error: ImportError: No module named 'apscheduler'.

I tried to install the older version with: sudo pip uninstall apscheduler and then sudo pip install apscheduler==2.1.2 but this doesn't worked for me.

Here's my code:

import os ,subprocess
from apscheduler.schedulers.blocking import BlockingScheduler



def scheduled_job():
    sync_to_drive=subprocess.check_output(["./gdrive", "sync", "upload", "--keep-local", "/home/pi/Documents"], cwd="/home/pi/Downloads") 
    print (sync_to_drive)

sched = BlockingScheduler()
sched.add_job(scheduled_job, "interval", seconds=5)
sched.start()
like image 361
Pietro Ariano Avatar asked Feb 20 '17 19:02

Pietro Ariano


Video Answer


2 Answers

I see python-3.x tag in your question, so you might be using python3, try pip3 install apscheduler and see if it helps.

like image 62
chengbo Avatar answered Oct 19 '22 16:10

chengbo


you should use

from apscheduler.schedulers.background import BackgroundScheduler

,this is the code from new version.

like image 28
dytj Avatar answered Oct 19 '22 15:10

dytj