简体   繁体   English

Python计划脚本在IDLE中运行,但不在Visual Studio Code中运行

[英]Python schedule script running in IDLE but not in Visual Studio Code

The following test code runs perfectly in Python IDLE but in Visual Studio Code I get an error message that says: 以下测试代码可以在Python IDLE中完美运行,但是在Visual Studio Code中,我收到一条错误消息,内容为:

"AttributeError: 'module' object has no attribute 'every' ..." “ AttributeError:'模块'对象没有属性'每个'...”

import schedule  
import time  
def job(t):  
    print "I'm working..." , t  
    return  
schedule.every().day.at("08:16").do(job,'hello')  
while True:  
    schedule.run_pending()  
    time.sleep(60) # wait one minute  

I am trying to schedule a recurring task in Python. 我正在尝试安排Python中的重复任务。 I've installed the schedule module and used the code to try it out. 我已经安装了schedule模块,并使用代码进行了试用。 Cleaning chache, renaming the file and re-writing it in a new file didn´t help. 清理文件,重命名文件并将其重新写入新文件并没有帮助。

How is it possible that a script runs in one application and not in the other?? 脚本怎么可能在一个应用程序中运行而不在另一个应用程序中运行? Does that make sense? 那有意义吗?

Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。

Can you do: 你可以做:

from schedule import * 
import schedule

Print: 打印:

print schedule.__file__ 

Also Be sure your file name, is not named: "schedule.py" 另外,请确保您的文件名未命名为:“ schedule.py”

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

相关问题 代码在python IDLE中工作但在visual studio中没有? - Code working in python IDLE but not in visual studio? Python elif 适用于 IDLE,但不适用于 Visual Studio Code - Python elif works in IDLE but not Visual Studio Code 为什么我的 Python 代码在 Visual Studio Code 中没有正确运行,但在 IDLE 中运行良好? - Why is my Python code not running correctly in Visual Studio Code, but runs fine in IDLE? Visual Studio Code 终端在 Powershell 中继续运行 Python 脚本 - Visual Studio Code Terminal keeps running Python script in Powershell 在 Visual Studio Code 中运行 python 脚本; 如何让 `input ()` 工作? - Running python script in Visual Studio Code; how to get `input ()` to work? 在bash中运行python脚本比在IDLE中运行代码慢 - running python script in bash slower than running code in IDLE Python Shell中运行代码的输出与IDLE中运行脚本的输出不同 - Output of running code in Python shell is different from running script in IDLE Python 在 Visual Studio Code 中找不到模块,但其他 IDLE 找到了它 - Python module not found in Visual Studio Code but other IDLE found it 从 VS 代码在 Python IDLE 中运行 python 脚本 - Running python script in Python IDLE from VS code 有没有办法在 visual studio 代码中使用 python IDLE Shell? - Is there any way to use the python IDLE Shell in visual studio code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM