zoukankan      html  css  js  c++  java
  • pyinstaller打包Django项目

    系统:ubuntu18.04 / Centos 7

    自带Python3.6

    1、安装pip3
         apt-get install -y python3-pip
         pip3 install --upgrade pip
        安装psycopg2报错
             解决:sudo apt-get install libpq-dev python-dev

    2、安装pyinstaller
        pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyinstaller
        进入项目根目录下执行pyi-makespec -D manage.py,生成manage.spec
    3、编辑manage.spec
        a = Analysis(['manage.py'],
                     pathex=[],
                     binaries=[],
                     datas=[('/root/projects/installer/GatewayServer/static', './static'), ('/root/projects/installer/GatewayServer/templates', './templates'), ('/root/projects/installer/GatewayServer/conf', './conf')],
                     hiddenimports=['django.contrib.admin',
                                    'django.contrib.auth',
                                    'django.contrib.contenttypes',
                                    'django.contrib.sessions',
                                    'django.contrib.messages',
                                    'django.contrib.staticfiles',
                                    'GWS',
                                    'ETGmini',
                                    'DemoGWS',
                                    'repository',
                                    'src.protocolPlugins.base',
                                    'src.protocolPlugins.etgmini',
                                    'src.protocolPlugins.etm100gw',
                                    'src.protocolPlugins.etm100sensor',],
                     hookspath=[],
                     hooksconfig={},
                     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,
                  [],
                  exclude_binaries=True,
                  name='manage',
                  debug=False,
                  bootloader_ignore_signals=False,
                  strip=False,
                  upx=True,
                  console=True,
                  disable_windowed_traceback=False,
                  target_arch=None,
                  codesign_identity=None,
                  entitlements_file=None )
        coll = COLLECT(exe,
                       a.binaries,
                       a.zipfiles,
                       a.datas,
                       strip=False,
                       upx=True,
                       upx_exclude=[],
                       name='manage')

    4、执行打包程序(目前只有在centos环境下可以打包成功):pyinstaller manage.spec,生成dist文件

  • 相关阅读:
    《Google, Microsoft and Apple building online storage havens: you win》
    asp数据库:ASP连接access与SQL SERVER数据库代码
    SQL SERVER中文编码问题
    tomcat与iis服务器的区别
    ewebeditor使用总结
    window.onload兼容ie和ff以及多次调用导致相冲突的解决方法
    js nextSibling属性和previousSibling属性
    安装ms word时需要的正版windows xp序列号
    asp中的父级目录
    asp数据库:Microsoft JET Database Engine (0x80004005)
  • 原文地址:https://www.cnblogs.com/yangyangming/p/15673244.html
Copyright © 2011-2022 走看看