首页 > 解决方案 > ModuleNotFoundError:使用 python3 时没有名为“apscheduler”的模块

问题描述

当我使用此命令启动我的项目时:

~/source/pydolphin on  master! ⌚ 15:52:02
$ python3.9 schedulespider.py                                                                          ‹ruby-2.7.2›
Traceback (most recent call last):
  File "/Users/dolphin/source/pydolphin/schedulespider.py", line 4, in <module>
    from apscheduler.schedulers.background import BackgroundScheduler
ModuleNotFoundError: No module named 'apscheduler'
(base)

然后我使用这个命令来安装apscheduler

conda install -c conda-forge apscheduler

但问题依然存在,我该怎么做才能解决它?这是我的 Python 代码:

# coding=utf-8

import time
from apscheduler.schedulers.background import BackgroundScheduler

from dolphin.biz.RssEntry import RssEntry

if __name__ == '__main__':
    scheduler = BackgroundScheduler()
    rss = RssEntry()
    scheduler.add_job(rss.rss_sub, 'cron', minute='*/1', max_instances=10)
    scheduler.start()
    try:
        while True:
            time.sleep(20)
    except (KeyboardInterrupt, SystemExit):
        scheduler.shutdown()

标签: python-3.x

解决方案


推荐阅读