pyinstaller打包成功,但是无法运行问题分析包含(pyecharts库)

原因一:
failed to execute script
分析:第三方库没有成功打包到exe文件。
分析步骤:
1)pyinstaller -F <主程序.py> -i <图标地址> -p <依赖环境文件夹1>; <依赖环境文件夹2>;
注意:不要加-w;不显示cmd命令框
2)在cmd中查看运行报错程序
以echarts示例:

报错1:FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\admin\AppData\Local\Temp\_MEI88722\pyecharts\datasets\map_filename.json’
原因:pyecharts当前不支持pyinstaller打包,兼容性差(2020.12.21),希望pyechart越来越好,毕竟真的赞
解决方法:
完美打包:https://blog.csdn.net/huhu1986/article/details/109388027
在此就不多说了,注意看评论区还能帮到忙。
半成品打包:https://blog.csdn.net/weixin_43865152/article/details/93781051

报错2:pkg_resources.DistributionNotFound: The ‘prettytable’ distribution was not found and is required by the application
原因:打包pyecharts依赖的其他环境未找到,这里指的是prettytable.其他的处理方法类似
解决方法:
1.进入python环境的第三方库目录:
…\Lib\site-packages\PyInstaller\hooks
新增hook-pycparser.py文件,因为不兼容,所以没有这个文件

#-----------------------------------------------------------------------------
# Copyright (c) 2017-2020, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

# Hook for nanite: https://pypi.python.org/pypi/nanite

from PyInstaller.utils.hooks import collect_data_files,copy_metadata

datas = collect_data_files('pyecharts')+copy_metadata('prettytable')

缺少哪个文件就追加对应的文件:+copy_metadata(’ 缺少的文件名’)
注意导入库文件
https://www.pianshen.com/article/9248147413/

2.pyinstaller -F <主程序.py> -i <图标地址> -p <依赖环境文件夹1>; <依赖环境文件夹2>; --additional-hooks-dir=.
注意后边还有“.”

在此记录问题,感谢以上链接博主,帮我解决问题。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值