参考链接:
1、https://blog.youkuaiyun.com/pipisorry/article/details/50620495
2、https://pythonhosted.org/PyInstaller/spec-files.html#adding-data-files
在py3.6使用pyinstaller打包时很顺利,但是在执行exe文件时报错:
FileNotFoundError: [Errno 2] No such file or directory: 'logging.json'
[5648] Failed to execute script agent
因为出错的这个文件恰恰不是py文件,也不是其他,而是配置文件,一开始并没有想到这是数据文件,但我觉得肯定是因为这个文件类型不同的原因。
解决办法有两个:
1、最简单的就是将跟.json相关的文件放到dist目录下(生成的exe在dist目录下,并且要使用exe时,要挪动一整个dist目录),执行就OK了。
2、打开.spec文件,里面 有一个
a = Analysis(['your_py.py'],
pathex=['your_py_path'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,