各位大家好,感谢您抽出宝贵时间帮助我.
我目前正在尝试使用PyInstaller(3.1)为我的Kivy(1.9.1)应用程序创建一个Windows包.我按照文档中的说明进行操作但无法使用.所以我尝试使用演示应用程序’touchtracer’作为示例给出相同的结果.我收到以下错误:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "f:\temp\pip-build-1elcla\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 48, in <module>
from pkg_resources.extern import six
File "C:\Python27\lib\site-packages\pkg_resources\extern\__init__.py", line 60, in load_module
"distribution.".format(**locals())
ImportError: The 'six' package is required; normally this is bundled
with this package so if you get this warning, consult the packager of
your distribution.
pyi_rth_pkgres returned -1
这是我的.spec文件:
# -*- mode: python -*-
from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['C:\\Python27\\share\\kivy-examples\\demo\\touchtracer\\main.py'],
pathex=['C:\\Users\\PC\\Documents\\Njord\\njord\\Nouveau dossier'],
binaries=None,
datas=None,
hiddenimports=[],
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='touchtracer',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe, Tree('C:\\Python27\\share\\kivy-examples\\demo\\touchtracer\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='touchtracer')
我尝试过使用pip和wheel方法安装的Kivy软件包,但没有成功.有人有解释吗?
再次感谢.
解决方法:
我设法找到了解决问题的方法.我试图将“six”包添加到hidden_imports,但随后它是缺少的“打包”包.
然后我通过简单的安装安装了setuptools 19.4,这次,即使我的hidden_imports中有“六个”,我得到了第一个错误,还有很多警告.
我环顾四周,有几个人说setuptools 19.4有问题,应该恢复到19.2.我做了它,然后它是缺少kivy.app,但它是进步.
我将kivy添加到spec文件中的hidden_imports,这导致另一个错误,说我的一个模块出现了属性错误.我只需要添加其他依赖项(sqlalchemy,sqlalchemy.orm,uuid).
快速回顾一下:如果安装了setuptools,请确保它是19.2.将外部依赖项添加到hidden_imports,包括kivy.