Pyinstaller编译为exe

Tba*_*ker 7 python windows pyinstaller

我试图将一个Kivy应用程序编译到一个Windows exe,但我一直收到一个属性错误:AttributeError:'str'对象没有属性'items'

我编译了其他应用程序,并按照kivy页面的说明行(完成演示),但当我尝试对我的应用程序执行相同操作时,我收到上述错误.我不知道该去哪里我已经尝试了好几个小时了,我似乎无法取得任何进展.任何帮助将不胜感激.

编辑:下面是堆栈跟踪的尾部,整个事情很长,所以我粘贴在我认为可能相关的内容中,但坦率地说,我有点超出我的深度:)

6363 WARNING: stderr:   File "c:\python27\lib\site-packages\PyInstaller\depend\a
nalysis.py", line 198, in _safe_import_module
     hook_module.pre_safe_import_module(hook_api)
6375 WARNING: stderr:     hook_module.pre_safe_import_module(hook_api)
   File "c:\python27\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\
hook-six.moves.py", line 55, in pre_safe_import_module
6378 WARNING: stderr:   File "c:\python27\lib\site-packages\PyInstaller\hooks\pr
e_safe_import_module\hook-six.moves.py", line 55, in pre_safe_import_module
     for real_module_name, six_module_name in real_to_six_module_name.items():
6388 WARNING: stderr:     for real_module_name, six_module_name in real_to_six_m
odule_name.items():
 AttributeError: 'str' object has no attribute 'items'
6396 WARNING: stderr: AttributeError: 'str' object has no attribute 'items'
Run Code Online (Sandbox Code Playgroud)

我的规格:

# -*- mode: python -*-
from kivy.deps import sdl2, glew

block_cipher = None


a = Analysis(['face.py'],
             pathex=['c:\\Users\\Home\\PycharmProjects\\MSICheck\\Images'],
             binaries=None,
             datas=None,
             hiddenimports=['sqlite3','kivy.app','six','packaging','packaging.version','packaging.specifiers'],
             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='face',
          debug=True,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,Tree('c:\\Users\\Home\\PycharmProjects\\MSICheck\\Images\\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='face')
Run Code Online (Sandbox Code Playgroud)

编辑:显然它与Kivy无关,因为我已经改写前端使用TKinter而我仍然有问题.

Bea*_*ard 20

如果你还有这个问题,这就解决了我的问题:

pip install --upgrade setuptools
Run Code Online (Sandbox Code Playgroud)

我已经尝试安装六个(在我的情况下,它还没有安装),但因为它似乎正在寻找_vendor.six而不仅仅是six,这并没有解决它.不知何故,升级setuptools解决了它.


小智 7

尝试使用pyinstaller将我的脚本编译为猛男时,我遇到了类似的错误。我尝试按照其他地方的建议卸载/重新安装六个和setuptools,但没有任何效果。我注意到有关enum的另一个错误,并尝试通过pip卸载enum34。做到了。

pip uninstall enum34
Run Code Online (Sandbox Code Playgroud)