微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pyinstaller打包apscheduler问题的解决方法

软硬件环境

  • ubuntu 16.04 64bit

  • python3.5

  • apscheduler 3.3.1
  • pyintaller 3.2.1

问题描述

最近在项目中用到了apscheduler这个库,用来做定时任务非常的好,使用也很简单,不过在pyinstaller打包工程的时候,出现了如下错误

解决方法

编辑文件/usr/local/lib/python3.5/dist-packages/apscheduler/__init__.py

# These will be removed in APScheduler 4.0.
# release = __import__('pkg_resources').get_distribution('APScheduler').version.split('-')[0]
# version_info = tuple(int(x) if x.isdigit() else x for x in release.split('.'))
# version = __version__ = '.'.join(str(x) for x in version_info[:3])

release = (3,3,1) 
version_info = '3.3.1' 
version = '3.3.1'

3.3.1是我安装的apscheduler的版本号,视实际情况修改

接下来创建一个名称为hook-ctypes.macholib.py,内容如下

# -*- coding: utf-8 -*-

from PyInstaller.utils.hooks import copy_Metadata

datas = copy_Metadata('apscheduler')

打包命令

pyinstaller -F --clean --additional-hooks-dir . --distpath release main.py

参考资料

1、https://pypi.python.org/pypi/APScheduler

2、https://github.com/agronholm/apscheduler/issues/131

原文地址:https://www.jb51.cc/ubuntu/351321.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐