简体   繁体   English

加载/安装计划 python 模块时出错

[英]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' ModuleNotFoundError:没有名为“计划”的模块

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)我用 pip 安装它,事实上,如果我尝试执行pip 安装计划,我会得到Requirement already satisfied: schedule in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\agelocalcache1 \网站包(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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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