python pyinstaller 打包

2018-09-22  本文已影响0人  SoJax

多次试验使用pip install pyinstaller安装pyinstaller在打包过程中均出现各种问题,直接在github下载源码打包

  1. 直接在github上下载源码git clone https://github.com/pyinstaller/pyinstaller.git

  2. 参照官方文档

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).
  1. 创建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 )
  1. 打包成可执行文件python3 pyinstaller.py main.spec
上一篇下一篇

猜你喜欢

热点阅读