Python pyinstaller打包pyechart的最佳方法

个人博客,欢迎来撩 fangzengye.com



  1. 打包pyechart错误信息

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\xxx\AppData\Local\Temp\_MEI944442\pyecharts\datasets\map_filename.json’

2.原因: pyinstaller与yechart不兼容
3.方法:在PyInstaller安装目录下

  • \AppData\Roaming\Python\Python37\site-packages\PyInstaller\hooks\ 需要增加如下文件,

hook-pyecharts.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 
datas = collect_data_files('pyecharts') 

然后删除工程下面xxxxx.spec 文件,重新打包,即可。

主要参考:refers1
refers2

posted @ 2020-12-01 17:40  开源的Boy  阅读(1505)  评论(1)    收藏  举报