APScheduler - ImportWarning 但代码仍在运行。怎么了?
APScheduler - ImportWarning but code still runs. What is wrong?
我的代码遵循 APScheduler Docs 中的示例,但我更改了其格式以遵循我的代码。没问题。 "Hello World" 每 10 秒打印一次。
#! /usr/bin/python
import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
class Class1:
def job_function():
print("Hello World")
class Class2:
def go():
sched = BlockingScheduler()
# Schedule job_function to be called every 10 seconds
sched.add_job(Classy.job_function, 'interval', seconds = 10)
sched.start()
if __name__ == '__main__':
Class2.go()
然而,我的实际代码并不能很好地工作。
#! /usr/bin/python
import time
import praw
import OAuth2Util
import redditNewsBot
import redditFreeGameBot
import redditWorldNewsBot
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
class Aggregate:
def aggr()
...
def x():
print('x')
class RunSchedule:
def go():
sched = BlockingScheduler()
# Schedule job_function to be called every ten seconds
sched.add_job(Aggregate.x, 'interval', seconds = 10)
sched.start()
if __name__ == '__main__':
RunSchedule.go()
一切都会 运行 在指定的时间间隔,但我首先得到所有这些:
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mpl_toolkits: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
c:\users\nick\appdata\local\programs\python\python35-32\lib\site-packages\mpl_toolkits: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\site-packages\zope: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
是praw
。
我将它导入到 datetime
和 from apscheduler.schedulers.blocking import BlockingScheduler
后面的测试脚本中,它 运行 没有错误。
然后我把它移到后者前面,它抛出了错误。
为了运行错误从apscheduler.schedulers.blocking import BlockingSchedulerhad
移到导入列表的最前面。 time
和 datetime
也可以在前面而不会出错。
from apscheduler.schedulers.blocking import BlockingScheduler
import praw
import time
import datetime
import OAuth2Util
import redditNewsBot
import redditFreeGameBot
import redditWorldNewsBot
我的代码遵循 APScheduler Docs 中的示例,但我更改了其格式以遵循我的代码。没问题。 "Hello World" 每 10 秒打印一次。
#! /usr/bin/python
import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
class Class1:
def job_function():
print("Hello World")
class Class2:
def go():
sched = BlockingScheduler()
# Schedule job_function to be called every 10 seconds
sched.add_job(Classy.job_function, 'interval', seconds = 10)
sched.start()
if __name__ == '__main__':
Class2.go()
然而,我的实际代码并不能很好地工作。
#! /usr/bin/python
import time
import praw
import OAuth2Util
import redditNewsBot
import redditFreeGameBot
import redditWorldNewsBot
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
class Aggregate:
def aggr()
...
def x():
print('x')
class RunSchedule:
def go():
sched = BlockingScheduler()
# Schedule job_function to be called every ten seconds
sched.add_job(Aggregate.x, 'interval', seconds = 10)
sched.start()
if __name__ == '__main__':
RunSchedule.go()
一切都会 运行 在指定的时间间隔,但我首先得到所有这些:
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mpl_toolkits: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
c:\users\nick\appdata\local\programs\python\python35-32\lib\site-packages\mpl_toolkits: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\importlib\_bootstrap_external.py:415: ImportWarning: Not importing directory
C:\Users\Nick\AppData\Local\Programs\Python\Python35-32\lib\site-packages\zope: missing __init___warnings.warn(msg.format(portions[0]), ImportWarning)
是praw
。
我将它导入到 datetime
和 from apscheduler.schedulers.blocking import BlockingScheduler
后面的测试脚本中,它 运行 没有错误。
然后我把它移到后者前面,它抛出了错误。
为了运行错误从apscheduler.schedulers.blocking import BlockingSchedulerhad
移到导入列表的最前面。 time
和 datetime
也可以在前面而不会出错。
from apscheduler.schedulers.blocking import BlockingScheduler
import praw
import time
import datetime
import OAuth2Util
import redditNewsBot
import redditFreeGameBot
import redditWorldNewsBot