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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM