问题描述
我正在尝试将 Kivy 应用程序编译为 Windows exe,但我一直收到属性错误:AttributeError: 'str' 对象没有属性 'items'
I am trying to compile a Kivy application to a windows exe, but I keep receiving an attribute error:AttributeError: 'str' object has no attribute 'items'
我已经编译了其他应用程序,并按照 kivy 页面(完成演示),但是当我尝试对我的应用程序执行相同操作时,我收到上述错误.我不知道该去哪里我已经尝试了几个小时,但似乎没有任何进展.任何帮助将不胜感激.
I have compiled other applications, and followed the instructions line for line per the kivy page (completing the demo), but when I try to do the same to my application I receive the above error. I'm not sure where to go I've been trying for several hours now and I can't seem to make any headway. Any help would be greatly appreciated.
下面是堆栈跟踪的尾部,整个事情很长,所以我粘贴了我认为可能相关的内容,但坦率地说,我在这里有点超出我的深度:)
Below is the tail of the stack trace, the whole thing is long and so I pasted in what I think may be relevant, but frankly I'm a bit out of my depth here :)
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,但我仍然遇到问题.
Apparently it has nothing to do with Kivy as I have rewritten the front end to use TKinter and i'm still having the issue.
推荐答案
如果您仍然遇到此问题,以下是为我解决的方法:
If you are still having this issue, here is what solved it for me:
pip install --upgrade setuptools
我试过安装六个(在我的例子中,它还没有安装),但因为它似乎在寻找 _vendor.six
而不仅仅是 six,这并没有解决它.不知何故,升级 setuptools 解决了这个问题.
I've tried installing six (in my case, it wasn't already installed), but since it seems that it is looking for
_vendor.six
and not just six
, that didn't solve it. Somehow, upgrading setuptools solves it.
这篇关于Pyinstaller 编译成exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!