python3 pyinstaller pyppeteer NameError(“name ‘__version__‘ is not defined“)

在使用pyppeteer+pyinstaller打包运行浏览器模拟程序时,出现NameError("name '__version__' is not defined") 错误问题。

导致该问题的原因是由于pyinstaller打包时没将pyppeteer的meta信息打进去,导致运行时候报错。

解决方式:增加 --copy-metadata参数


import PyInstaller.__main__
import os


if __name__ == '__main__':
    pyi_args = [
        '--upx-dir=F:\\soft\\upx-3.96-win64',
        '--clean',
        '--add-data={0};.'.format(os.path.realpath('config.ini')),
        '--add-data={0};data'.format(os.path.realpath('data')),
        '--add-data={0};static'.format(os.path.realpath('static')),
        '--add-data={0};templates'.format(os.path.realpath('templates')),
        '--copy-metadata=pyppeteer',
        '--name=demo',
        'main.py',
        '-y'
    ]
    print("pyinstaller " + " ".join(pyi_args))
    PyInstaller.__main__.run(pyi_args=pyi_args)

参考:pyppeteer-issues

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值