如何将UPX与pyinstaller一起使用?
我在看医生。
我已经下载了UPX。
我的文件看起来像:
import csv
import selenium
import pandas
print('Hello')
然后我跑:
pyinstaller -F --upx-dir C:\Users\DD\Downloads\upx394w\upx394w\123\upx308w\upx.exe zz.spec
这不会影响文件的大小。
你知道我怎样才能让它工作吗?
# -*- mode: python -*-
block_cipher = None
a = Analysis(['zz.py'],
pathex=['C:\\Users\\DA\\13\\14'],
binaries=[],
datas=[],
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,
a.binaries,
a.zipfiles,
a.datas,
name='zz',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
添加一个新的答案,因为现在(2019年9月)PyInstaller似乎比当前的答案和评论建议的更有帮助。
如果UPX正在工作,我会在构建的早期看到输出
934 INFO: UPX is available.
。另外,我可以看到PyInstaller调用upx的许多输出行。
我没有指定
--upx-dir
,但是在我的$PATH
环境变量中有upx.exe
可用。除了GlennS的注释:确切的说,这种行为在
pyinstaller
文档中有说明。因此,在这方面,这并不是一个无证的意外收益。见https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html#using-upx
需要指定UPX目录,而不是UPX可执行文件:
例如:
pyinstaller myfile.py --upx-dir=..\upx391w -y --onefile
相关问题 更多 >
编程相关推荐