当前位置: 首页 > article >正文

手动将python的flask程序打包成exe在windows上执行

1、安装pyinstaller工具

(venv) PS D:\django\locallibrary> pip install pyinstaller
Collecting pyinstaller
  Downloading pyinstaller-6.11.0-py3-none-win_amd64.whl.metadata (8.4 kB)
Requirement already satisfied: setuptools>=42.0.0 in d:\django\locallibrary\venv\lib\site-packages (from pyinstaller) (75.1.0)
Collecting altgraph (from pyinstaller)
  Downloading altgraph-0.17.4-py2.py3-none-any.whl.metadata (7.3 kB)
Collecting pyinstaller-hooks-contrib>=2024.8 (from pyinstaller)
  Downloading pyinstaller_hooks_contrib-2024.9-py3-none-any.whl.metadata (16 kB)
Requirement already satisfied: packaging>=22.0 in d:\django\locallibrary\venv\lib\site-packages (from pyinstaller) (24.1)
Collecting pefile!=2024.8.26,>=2022.5.30 (from pyinstaller)
  Downloading pefile-2023.2.7-py3-none-any.whl.metadata (1.4 kB)
Collecting pywin32-ctypes>=0.2.1 (from pyinstaller)
  Downloading pywin32_ctypes-0.2.3-py3-none-any.whl.metadata (3.9 kB)
Downloading pyinstaller-6.11.0-py3-none-win_amd64.whl (1.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 33.6 MB/s eta 0:00:00
Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
Downloading pyinstaller_hooks_contrib-2024.9-py3-none-any.whl (336 kB)
Downloading pywin32_ctypes-0.2.3-py3-none-any.whl (30 kB)
Downloading altgraph-0.17.4-py2.py3-none-any.whl (21 kB)
Installing collected packages: altgraph, pywin32-ctypes, pyinstaller-hooks-contrib, pefile, pyinstaller
Successfully installed altgraph-0.17.4 pefile-2023.2.7 pyinstaller-6.11.0 pyinstaller-hooks-contrib-2024.9 pywin32-ctypes-0.2.3

2、打包

(venv) PS D:\django\locallibrary> cd .\websocket_test\
(venv) PS D:\django\locallibrary\websocket_test> pyinstaller --onefile --add-data "templates;templates" --add-data "static;static" app.py
392 INFO: PyInstaller: 6.11.0, contrib hooks: 2024.9
393 INFO: Python: 3.12.3
429 INFO: Platform: Windows-11-10.0.22631-SP0
429 INFO: Python environment: D:\django\locallibrary\venv
430 INFO: wrote D:\django\locallibrary\websocket_test\app.spec
433 INFO: Module search paths (PYTHONPATH):
['D:\\django\\locallibrary\\venv\\Scripts\\pyinstaller.exe',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python312\\python312.zip',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python312\\DLLs',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python312\\Lib',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python312',
 'D:\\django\\locallibrary\\venv',
 'D:\\django\\locallibrary\\venv\\Lib\\site-packages',
 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\setuptools\\_vendor',
 'D:\\django\\locallibrary\\websocket_test']
806 INFO: Appending 'datas' from .spec
807 INFO: checking Analysis
808 INFO: Building Analysis because Analysis-00.toc is non existent
808 INFO: Running Analysis Analysis-00.toc
808 INFO: Target bytecode optimization level: 0
808 INFO: Initializing module dependency graph...
816 INFO: Initializing module graph hook caches...
828 INFO: Analyzing base_library.zip ...
2034 INFO: Processing standard module hook 'hook-heapq.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
2103 INFO: Processing standard module hook 'hook-encodings.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
3587 INFO: Processing standard module hook 'hook-pickle.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
4761 INFO: Caching module dependency graph...
4843 INFO: Looking for Python shared library...
4852 INFO: Using Python shared library: C:\Users\Administrator\AppData\Local\Programs\Python\Python312\python312.dll
4853 INFO: Analyzing D:\django\locallibrary\websocket_test\app.py
5057 INFO: Processing pre-safe-import-module hook 'hook-typing_extensions.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
5059 INFO: SetuptoolsInfo: initializing cached setuptools info...
8643 INFO: Processing standard module hook 'hook-jinja2.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
9221 INFO: Processing standard module hook 'hook-multiprocessing.util.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
9305 INFO: Processing standard module hook 'hook-xml.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
10367 INFO: Processing standard module hook 'hook-cryptography.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
11958 INFO: Processing standard module hook 'hook-platform.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
12083 INFO: Processing standard module hook 'hook-sysconfig.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
12450 INFO: Processing standard module hook 'hook-difflib.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
12511 INFO: Processing pre-safe-import-module hook 'hook-importlib_metadata.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
12512 INFO: Setuptools: 'importlib_metadata' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.importlib_metadata'!
12532 INFO: Processing standard module hook 'hook-setuptools.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
12559 INFO: Processing pre-safe-import-module hook 'hook-distutils.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
12582 INFO: Processing pre-safe-import-module hook 'hook-jaraco.functools.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
12585 INFO: Setuptools: 'jaraco.functools' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.functools'!
12599 INFO: Processing pre-safe-import-module hook 'hook-more_itertools.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
12600 INFO: Setuptools: 'more_itertools' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.more_itertools'!
12848 INFO: Processing pre-safe-import-module hook 'hook-packaging.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
12868 INFO: Processing standard module hook 'hook-packaging.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
13032 INFO: Processing pre-safe-import-module hook 'hook-jaraco.text.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13034 INFO: Setuptools: 'jaraco.text' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.text'!
13042 INFO: Processing standard module hook 'hook-setuptools._vendor.jaraco.text.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
13044 INFO: Processing pre-safe-import-module hook 'hook-importlib_resources.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13044 INFO: Setuptools: 'importlib_resources' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.importlib_resources'!
13081 INFO: Processing pre-safe-import-module hook 'hook-zipp.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13082 INFO: Setuptools: 'zipp' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.zipp'!
13106 INFO: Processing pre-safe-import-module hook 'hook-jaraco.context.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13106 INFO: Setuptools: 'jaraco.context' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.context'!
13114 INFO: Processing pre-safe-import-module hook 'hook-backports.tarfile.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13114 INFO: Setuptools: 'backports.tarfile' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.backports.tarfile'!
13190 INFO: Processing standard module hook 'hook-backports.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
13459 INFO: Processing pre-safe-import-module hook 'hook-tomli.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
13460 INFO: Setuptools: 'tomli' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.tomli'!
13954 INFO: Processing standard module hook 'hook-pkg_resources.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
14346 INFO: Processing pre-safe-import-module hook 'hook-platformdirs.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
14346 INFO: Setuptools: 'platformdirs' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.platformdirs'!
14467 INFO: Processing pre-safe-import-module hook 'hook-wheel.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
14468 INFO: Setuptools: 'wheel' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.wheel'!
14633 INFO: Processing standard module hook 'hook-setuptools._vendor.importlib_metadata.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks'
15096 INFO: Processing module hooks (post-graph stage)...
15463 INFO: Performing binary vs. data reclassification (19 entries)
15510 INFO: Looking for ctypes DLLs
15542 INFO: Analyzing run-time hooks ...
15545 INFO: Including run-time hook 'pyi_rth_inspect.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
15547 INFO: Including run-time hook 'pyi_rth_cryptography_openssl.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\rthooks'
15548 INFO: Including run-time hook 'pyi_rth_pkgutil.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
15550 INFO: Including run-time hook 'pyi_rth_multiprocessing.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
15552 INFO: Including run-time hook 'pyi_rth_setuptools.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
15554 INFO: Including run-time hook 'pyi_rth_pkgres.py' from 'D:\\django\\locallibrary\\venv\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
15564 INFO: Looking for dynamic libraries
16752 INFO: Extra DLL search directories (AddDllDirectory): []
16752 INFO: Extra DLL search directories (PATH): []
17062 INFO: Warnings written to D:\django\locallibrary\websocket_test\build\app\warn-app.txt
17114 INFO: Graph cross-reference written to D:\django\locallibrary\websocket_test\build\app\xref-app.html
17142 INFO: checking PYZ
17143 INFO: Building PYZ because PYZ-00.toc is non existent
17143 INFO: Building PYZ (ZlibArchive) D:\django\locallibrary\websocket_test\build\app\PYZ-00.pyz
17873 INFO: Building PYZ (ZlibArchive) D:\django\locallibrary\websocket_test\build\app\PYZ-00.pyz completed successfully.
17924 INFO: checking PKG
17924 INFO: Building PKG because PKG-00.toc is non existent
17925 INFO: Building PKG (CArchive) app.pkg
20455 INFO: Building PKG (CArchive) app.pkg completed successfully.
20457 INFO: Bootloader D:\django\locallibrary\venv\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
20458 INFO: checking EXE
20458 INFO: Building EXE because EXE-00.toc is non existent
20458 INFO: Building EXE from EXE-00.toc
20458 INFO: Copying bootloader EXE to D:\django\locallibrary\websocket_test\dist\app.exe
20739 INFO: Copying icon to EXE
21050 INFO: Copying 0 resources to EXE
21050 INFO: Embedding manifest in EXE
21365 INFO: Appending PKG archive to EXE
21376 INFO: Fixing EXE headers
21447 INFO: Building EXE from EXE-00.toc completed successfully.

3、查询编译后的目录结果
在这里插入图片描述


http://www.kler.cn/news/364883.html

相关文章:

  • [CSP-J 2023] 一元二次方程(模拟)
  • AI智能电销机器人有什么功能?语音机器人系统搭建
  • Modbus TCP报错:Response length is only 0 bytes
  • Notepad++通过自定义语言实现日志按照不同级别高亮
  • 【32】C++流
  • 京准电钟HR-901GB双GPS北斗卫星时钟服务器
  • Zabbix企业级分布式监控环境部署
  • Solidworks 选项卡不显示草图、焊件等选项
  • Docker 搭建mysql
  • 15.6 JDBC数据库编程6——可滚动和可更新的ResultSet
  • FFMPEG录屏(20)--- 枚举macOS下的窗口和屏幕列表,并获取名称缩略图等信息
  • OpenCV系列教程六:信用卡数字识别、人脸检测、车牌/答题卡识别、OCR
  • 利用飞腾派进行OpenCV开发
  • 【C++修炼】初识C++:命名空间、缺省参数、函数重载、引用、内联函数、指针空值
  • java编译[WARNING]告警处理
  • OpenCV KeyPoint与描述子编解码
  • 搭建你的第一个Spring Cloud Alibaba微服务
  • Java | Leetcode Java题解之第492题构造矩形
  • 论文引用收录证明有什么用?
  • vue2之混入(mixin)
  • python的接口自动化的测试与实现java监测jsp源代码Mysql
  • 【React系列二】—React学习历程的分享
  • 2024 JavaScript 入门教程:语法、算法与重要知识点详解
  • 查看linux的版本
  • 电影评论网站开发:Spring Boot技术指南
  • K最近邻算法