首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google api和APscheduler

google api和APscheduler
EN

Stack Overflow用户
提问于 2017-12-26 15:07:51
回答 1查看 146关注 0票数 0

所以我遇到的这些库的问题是,如果我使用的是APscheduler版本3,那么当我尝试用cx_freeze编译python脚本时,它拒绝编译

错误消息:

"ImportError:没有名为‘apscheduler.executors.base_py3’的模块“

当我尝试用2.1.2版本编译它时,它会编译,但在运行时抛出一个错误,说它无法从apscheduler.schedulers.blocking导入BlockingScheduler导入

有没有人知道解决这个问题的方法或解决方案?

代码如下:

代码语言:javascript
复制
import gspread, time, requests
from oauth2client.service_account import ServiceAccountCredentials
from apscheduler.schedulers.blocking import BlockingScheduler


def update():
    print("used")
    scope = ['https://spreadsheets.google.com/feeds']
    creds = ServiceAccountCredentials.from_json_keyfile_name('details.json', scope)
    client = gspread.authorize(creds)
    sheet = client.open('ip_display').sheet1

    userip = (requests.get("http://jsonip.com/").json())["ip"]

    row = [userip, ]

    sheet.update_cell(2, 1, userip)
    sheet.update_cell(2, 2, time.strftime("%H:%M:%S"))


scheduler = BlockingScheduler()
job = scheduler.add_job(update, 'interval', hours=1)

scheduler.start()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-29 08:40:18

cx_freeze依赖于启发式方法来确定哪些模块要包含,哪些模块不要。这在APScheduler中失败了,因为它依赖于入口点(因此是动态导入)。因此,您必须显式地将apscheduler包添加到cx_freeze的所需模块列表中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47975097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档