PyInstaller"ValueError:太多值无法解包" [英] PyInstaller "ValueError: too many values to unpack"

查看:180
本文介绍了PyInstaller"ValueError:太多值无法解包"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pyinstaller 3.2版

Pyinstaller version 3.2

操作系统:win10

OS: win10

我的python脚本在Winpython Python解释器中运行良好.

My python script work well in Winpython Python Interpreters.

但是当我使用Pyinstaller软件包时,python脚本包含caffe模块,我将面对这个问题:您可以加载I/O插件与 skimage.io.use_plugin "

But when I using Pyinstaller packages a python script include caffe module, I will face the problem: "You may load I/O plugins with the skimage.io.use_plugin"

我按照上面的回答修复了我的规范文件(挂钩文件?).而且我一直在收到以下错误:(ValueError:太多值无法解包)

I follow the answer above to fix my spec file(hook file??). And I have been getting following error: (ValueError: too many values to unpack)

Traceback (most recent call last):
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "D:\Python\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 223, in __init__
for name, pth in format_binaries_and_datas(datas, workingdir=spec_dir):
File "d:\python\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\PyInstaller\building\utils.py", line 440, in format_binaries_and_datas
for src_root_path_or_glob, trg_root_dir in binaries_or_datas:
ValueError: too many values to unpack

这是我的规格文件:

# -*- mode: python -*-
block_cipher = None

a = Analysis(['Demo_GenderAge.py'],
         pathex=['D:\\Work\\test_code\\PyInstaller_Test_caffe'],
         binaries=None,
         datas=["skimage.io._plugins"],
         hiddenimports=['skimage.io._plugins'],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)
exe = EXE(pyz,
      a.scripts,
      exclude_binaries=True,
      name='Demo_GenderAge',
      debug=False,
      strip=False,
      upx=True,
      console=True )
coll = COLLECT(exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           strip=False,
           upx=True,
           name='Demo_GenderAge')

有人可以告诉我如何解决吗?

Could some one please tell me how would i fix it?

推荐答案

datas 数组需要元组,而不是字符串.从 pyinstaller文档:

The datas array expects tuples, not strings. From the pyinstaller docs:

数据文件列表是元组列表.每个元组都有两个值,两者都必须是字符串:

The list of data files is a list of tuples. Each tuple has two values, both of which must be strings:

  • 第一个字符串指定文件或文件在系统中的位置.
  • 第二个字母指定运行时包含文件的文件夹的名称.

我想将上述信息应用于您的代码将导致以下结果:

I imagine applying the above information to your code would result in this:

...    
datas=[("skimage.io._plugins", '.')],
...

希望对您有帮助!

这篇关于PyInstaller"ValueError:太多值无法解包"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆