Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller "ValueError: too many values to unpack"

Pyinstaller version 3.2

OS: win10


My python script work well in Winpython Python Interpreters.

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

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

This is my spec file:

# -*- 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?

like image 997
Chi-Fang Hsieh Avatar asked Nov 18 '16 11:11

Chi-Fang Hsieh


1 Answers

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:

  • The first string specifies the file or files as they are in this system now.
  • The second specifies the name of the folder to contain the files at run-time.

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

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

I hope that helps!

like image 130
paulhauner Avatar answered Sep 20 '22 17:09

paulhauner