python - pyinstaller编译成exe

标签 python windows pyinstaller

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

我已经编译了其他应用程序,并按照 kivy page 的说明一行一行地进行操作(完成演示),但是当我尝试对我的应用程序执行相同操作时,我收到上述错误。我不确定该去哪里 我已经尝试了几个小时,但似乎没有取得任何进展。任何帮助将不胜感激。

编辑: 下面是堆栈跟踪的尾部,整个东西很长,所以我粘贴了我认为可能相关的内容,但坦率地说,我在这里有点力不从心:)

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'

我的规范:

# -*- 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')

编辑: 显然它与 Kivy 无关,因为我已经重写了前端以使用 TKinter,但我仍然遇到问题。

最佳答案

如果您仍然遇到此问题,以下是为我解决的方法:

pip install --upgrade setuptools

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

关于python - pyinstaller编译成exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35613300/

相关文章:

Python regex - 查找并计算字符序列

c# - AppWinStyle 不适用于 Process.start

windows - 如何在 Windows 中生成确定大小的文件?

python - 使用 pyinstaller 生成的 .exe 在其他 PC 上崩溃 - 如何创建真正没有依赖项的 .exe?

python - 编译调用配置文件

python - ArangoDB 读取超时(读取超时=60)

python - 如何使用 python 将波斯语文本保存在 csv 文件中?

python - 高效获取正方形线上的格点

python - 使 PyInstaller exe 同时执行命令行和窗口

python - PyInstaller 使用 pip 安装了 'successfully' 但找不到 pyinstaller.py