pyinstaller添加外部文件打包出错(for src_root_path_or_glob, trg_root_dir in binaries_or_datas: ValueError: too many values to unpack (expected 2))解决办法

for src_root_path_or_glob, trg_root_dir in binaries_or_datas:
ValueError: too many values to unpack (expected 2)

 

打包时出错。大概率问题出在  编辑spec文件时出错。

a = Analysis(['kaishi.py'],
             pathex=[],
             binaries=[],
             datas=[('1.jpg)],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

问题出在 

datas=[('1.jpg)],

这个打包限制,最起码两个以上打包,所以要改写代码。

datas=[('1.jpg','.')],

这样就可以成功打包。也可以加点其他附加东西。 最终就这样。

a = Analysis(['kaishi.py'],
             pathex=[],
             binaries=[],
             datas=[('1.jpg','.')],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

可以成功打包了。 前提是修改了spec  datas属性打包失败的解决办法。

1639 INFO: Updating resource type 24 name 1 language 0
1646 INFO: Appending PKG archive to EXE
1963 INFO: Building EXE from EXE-00.toc completed successfully.
1967 INFO: checking COLLECT
1968 INFO: Building COLLECT because COLLECT-00.toc is non existent
1968 INFO: Building COLLECT COLLECT-00.toc
2190 INFO: Building COLLECT COLLECT-00.toc completed successfully.

 

posted @ 2022-01-06 12:42  凹凸曼大人  阅读(956)  评论(0编辑  收藏  举报