python pyinstaller 打包
2018-09-22 本文已影响0人
SoJax
多次试验使用pip install pyinstaller
安装pyinstaller
在打包过程中均出现各种问题,直接在github下载源码打包
-
直接在github上下载源码
git clone https://github.com/pyinstaller/pyinstaller.git
-
参照官方文档
Before using any contributed platform, you need to build the PyInstaller
bootloader, as we do not ship binary packages. Download PyInstaller
source, and build the bootloader::
cd bootloader
python ./waf distclean all
Then install PyInstaller::
python setup.py install
or simply use it directly from the source (pyinstaller.py).
- 创建
main.spec
文件
# -*- mode: python -*-
block_cipher = None
#__packagename__ ='your package name'
__packagename__ ='wechat_auto_reply'
a = Analysis(['/path/file1.py','/path/file2.py'],
pathex=['/path/pyinstaller-develop/' + __packagename__],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name= __packagename__,
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
- 打包成可执行文件
python3 pyinstaller.py main.spec