Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to package a python project into exe and installation packages

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to package python project into exe and installation package". In daily operation, I believe many people have doubts about how to package python project into exe and installation package. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to answer the doubts of "how to package python project into exe and installation package"! Next, please follow the small series to learn together!

I. Package Flask Project 1.1 Write your own Flask

2.2 Download pyinstallerip install pyinstaller Optional parameters example description-Fpyinstaller -F demo.py only generates a program demo.exe file in the dist folder, suitable for a module without multiple dependencies.py file-Dpyinstaller -D demo.py Default option, in addition to the main program demo.exe, will also generate a lot of dependent files in the dist folder, recommended to use this-cpyinstaller -c demo.py default option, only valid for windows, use console-wpyinstaller -w demo.py only valid for windows, Do not use console-ppyinstaller -p D:\project\demo.py to set import path-ipyinstaller-i D:\demo.ico demo.py Set a custom icon for the generated demo.exe file 2.3 Enter the project path and execute #run.py is the execution file of flask project, app.run is located in py file pyinstaller -D run.py #You can see the project path below -build folder -dist folder: important, there is a run folder (py file name), there is a run.exe (py file name) -run.spec #Copy the pro_flask folder to the run folder under dist - Because flask project has static files and html files, static files and html files will not be found if you do not copy the past - We can delete all Python code to hide the code, leaving only static and templates folders

2.4 Run exe, test #to dist/run folder, double-click run.exe, launch as shown below #browser access as shown below

II. NSIS: NSIS (Nullsoft Scriptable Install System) is an open source Windows installer that provides installation, uninstall, system settings, file decompression and other functions. As the name suggests, NSIS uses its scripting language to describe the behavior and logic of the installer. NSIS packages the run folder of dist just into a windows installation package.

2.2 zip the run folder under the dist folder

2.3 Use nsis to compress packages into windows installation files

At this point, the study on "how to package python projects into exe and installation packages" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report