如何查找仍兼容Python 2.7的最新APScheduler版本
确定兼容Python 2.7的最新APScheduler版本
用pip版本筛选逐步验证
在Python 2.7环境中,直接尝试从高到低安装APScheduler版本。先执行pip install apscheduler==3.10.0,若安装报错(提示Python版本不兼容),则依次降低版本号(如3.9.0、3.8.1等),直到找到能成功安装的最高版本。查看版本的setup.py元数据
用pip download apscheduler==<待验证版本号>下载对应版本的源码包,解压后查看根目录下的setup.py文件,找到python_requires字段——这个字段会明确标注该版本支持的Python版本范围。比如APScheduler 3.6.3的python_requires为>=2.7, !=3.0.*, !=3.1.*, !=3.2.*,而3.7.0及以上版本的该字段已改为>=3.6,由此可确认3.6.3是支持Python 2.7的最新稳定版本。编写简易脚本验证功能
安装候选版本后,运行以下测试脚本验证核心调度功能是否正常:from apscheduler.schedulers.blocking import BlockingScheduler def test_job(): print("测试任务执行成功") scheduler = BlockingScheduler() scheduler.add_job(test_job, 'interval', seconds=3) try: scheduler.start() except (KeyboardInterrupt, SystemExit): scheduler.shutdown()若脚本能正常启动、按时执行任务,说明该版本与Python 2.7兼容。
内容的提问来源于stack exchange,提问作者fashVR
相关产品推荐
相关产品推荐

