为了账号安全,请及时绑定邮箱和手机立即绑定

使用apscheduler进行Pyinstaller 3.3.1和3.4.0-dev构建

使用apscheduler进行Pyinstaller 3.3.1和3.4.0-dev构建

摇曳的蔷薇 2021-04-01 14:11:26
打招呼!我正在尝试使用PyInstaller进行构建。配置:Python 3.6.5 pip 10.0.1,操作系统:Ubuntu 18.04。使用virtualenv(也曾尝试与一起使用python -m venv)。我的应用程序使用apscheduler,websocket,_thread和它看起来像一些相关的模块有进口的问题。试过pyinstaller --onefile mymain.spec&pyinstaller --onedir mymain.spec。在两种情况下问题仍然存在。如果程序没有冻结,程序将正常运行。这是我尝试运行生成的可执行文件时遇到的错误:Traceback (most recent call last):  File "apscheduler/schedulers/base.py", line 882, in _create_plugin_instanceKeyError: 'interval'During handling of the above exception, another exception occurred:    Traceback (most recent call last):      File "cmonitorcli/services/socket_client.py", line 70, in run      File "cmonitorcli/services/scheduler.py", line 36, in add_update_job      File "apscheduler/schedulers/base.py", line 413, in add_job      File "apscheduler/schedulers/base.py", line 907, in _create_trigger      File "apscheduler/schedulers/base.py", line 890, in _create_plugin_instance    LookupError: No trigger by the name "interval" was found    ^CTraceback (most recent call last):      File "websocket/_app.py", line 283, in run_forever      File "websocket/_app.py", line 50, in read    KeyboardInterrupt    During handling of the above exception, another exception occurred:    Traceback (most recent call last):      File "cmonitorcli/main.py", line 20, in <module>      File "cmonitorcli/main.py", line 8, in main_job      File "cmonitorcli/client.py", line 29, in __init__      File "cmonitorcli/services/socket_client.py", line 31, in connect      File "websocket/_app.py", line 283, in run_forever    KeyboardInterruptrequirements.txt:jsonpickle==0.9.6pkg-resources==0.0.0six==1.11.0websocket-client==0.48.0apscheduler==3.5.1pyinstaller==3.3.1我需要进行--onefile构建。请注意hiddenimports与这些配合使用的示例:missing module named 'wsaccel.xormask' - imported by websocket._abnfmissing module named numpy - imported by websocket._abnfmissing module named win32evtlog - imported by logging.handlers和其他任何模块都无济于事-它们仍然会在日志中显示带有missing module标志
查看完整描述

3 回答

?
慕森卡

TA贡献1806条经验 获得超8个赞

根据Alex Grönholm回复:


问题的确是因为APScheduler使用setuptools入口点来查找触发器类。


解决方案是实例化触发器并传递给add_job():


from apscheduler.schedulers.background import BackgroundScheduler

from apscheduler.triggers import interval


scheduler = BackgroundScheduler()


trigger = interval.IntervalTrigger(seconds=3)

scheduler.add_job(lambda: job_func(ws), trigger=trigger, id='status_update_job', replace_existing=True)



查看完整回答
反对 回复 2021-04-20
?
桃花长相依

TA贡献1860条经验 获得超8个赞

问题在于pyinstaller不打包APScheduler查找触发器类所需的setuptools入口点。解决方法是手动导入和使用触发器。


查看完整回答
反对 回复 2021-04-20
  • 3 回答
  • 0 关注
  • 439 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号