APScheduler - ImportError: No module named 'apscheduler'
Asked Answered
M

4

7

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()
Manage answered 20/2, 2017 at 19:15 Comment(0)
P
15

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

Piscine answered 7/3, 2017 at 6:58 Comment(0)
C
4

you should use

from apscheduler.schedulers.background import BackgroundScheduler

,this is the code from new version.

Capriole answered 27/5, 2020 at 21:13 Comment(0)
S
0

If you are using anaconda use this to install apscheduler

conda install -c conda-forge apscheduler

conda install -c conda-forge/label/cf201901 apscheduler
Sombrero answered 31/1, 2019 at 5:35 Comment(0)
C
0

Uninstall apscheduler and then install it again. Will fix.

Cerebroside answered 11/10, 2019 at 3:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.