【发布时间】:2018-10-09 15:14:19
【问题描述】:
我正在构建一个 kivy 应用程序,我使用 PyInstaller 将其转换为可执行文件,它运行良好,但问题是有很多文件(.dll、.pyd...等)是用 Myapp 生成的.exe 在同一文件夹中。我想将应用程序提供给多个用户,并且我想将所有文件和文件夹放在一个文件夹中或最多 2 个文件夹中,Myapp.exe 除外。
我将它用于另一个应用程序,因为 cx_freeze 通过生成 lib 文件夹来实现。 Pyinstaller 没有生成这个文件夹,它显示与可执行文件在同一文件夹中的所有文件。
谁能帮我解决这个问题?
这是我的 .spec:
block_cipher = None
def get_pandas_path():
import pandas
pandas_path = pandas.__path__[0]
return pandas_path
a = Analysis(['Myapp.py'],
pathex=['C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\\\deskapp\\Code'],
binaries=[],
datas=[],
hiddenimports=['os','pandas','sys','kivy'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree
dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries)
dict_tree = Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\kv Scripts', prefix='kv Scripts', excludes=["*.pyc"])
a.datas += dict_tree
dict_tree = Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\Images_logo', prefix='Images', excludes=["*.pyc"])
a.datas += dict_tree
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='My app',
debug=False,
strip=False,
upx=True,
icon = 'C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\Images_logo\\MyIcon.ico',
console=False )
coll = COLLECT(exe,
Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\share\\glew\\bin\\'),
Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\share\\sdl2\\bin\\'),
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='My app')
这就是我在 dist 文件夹中得到的(生成 exe 的地方):
这就是我想要的(或类似的东西):
当我将 cx_freeze 与 base = 'Win32GUI' 一起使用时,我的应用程序没有出现,我只是将 cx_Freeze: Python error in main script 作为我的应用程序的标题我看不出是什么原因。
提前谢谢你
【问题讨论】:
标签: kivy pyinstaller cx-freeze