简体   繁体   中英

Error with loading/installing the schedule python module

i'm having issues with a test script for scheduling.

I need to do 2 groups of actions, the first group at one moment of each day, the second group in another moment of each day.

this is my code

import time
import schedule


def testA():
    print("test A")

def TestB():

    print("test B")

schedule.every().day.at("12:12").do(testA)
schedule.every().day.at("12:14").do(testB)

while True:
    schedule.run_pending()
    time.sleep(1)

not sure if the code is correct and will do what i need to, but at the moment it doesn't run at all, i get the following error

ModuleNotFoundError: No module named 'schedule'

I installed it with pip, in fact if i try to do pip install schedule i get Requirement already satisfied: schedule in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (1.1.0)

how can i fix this? thank you

This should solve the problem

import sys
sys.path.append(r"c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (1.1.0)")
    
import time
import schedule


def testA():
    print("test A")

def TestB():

    print("test B")

schedule.every().day.at("12:12").do(testA)
schedule.every().day.at("12:14").do(testB)

while True:
    schedule.run_pending()
    time.sleep(1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM