• 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文件

  • 相关阅读:
    使用python-docx生成Word文档
    python 日期格式转换
    Android开发:关于WebView
    用 jQuery.ajaxSetup 实现对请求和响应数据的过滤
    Mysql 命令大全
    旋转木马的小效果!
    CSS3 background-image背景图片相关介绍
    PHP的高效IOC框架——CanoeDI
    CSS3与页面布局学习总结(一)——概要、选择器、特殊性与刻度单位
    PHP入门介绍与环境配置
  • 原文地址:https://www.cnblogs.com/yangyangming/p/15673244.html
Copyright © 2020-2023  润新知