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 exe applications with python and how to install PyInstaller

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to package exe applications with python and how to install PyInstaller. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Introduction to PyInstaller

PyInstaller is a cross-platform Python application packaging tool that supports the three mainstream platforms of Windows/Linux/MacOS. It can package Python scripts and their Python interpreters into executable files, thus allowing end users to execute applications without installing Python.

The execution files produced by PyInstaller are not cross-platform, so if you need to package for different platforms, you need to run PyInstaller on the corresponding platform for packaging.

2. PyInstaller installation

Pip install Pyinstaller

Sometimes the installation fails? Install in the following ways

Pip install-I https://pypi.tuna.tsinghua.edu.cn/simple Pyinstaller

Permanent settin

Pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3. Prepare the required documents

Our tree folder is on disk c

Icons for fac.ico programs

Tree.py is a python file

4. Use Pyinstaller

Use the default Pyinstaller packaging method

Open the cmd window and change the path to the current path to open the command prompt

4.1 switch to English input method win+R open a command window and enter cmd

4.2 switch to the project directory

Be sure to change to the project directory and execute the packaging command

4.3 enter the command to package

Pyinstaller-F-I. / fac.ico tree.py

It is a success to see successfully after entering the command.

4.4 look at the result of the package

There are many more files and folders at this time.

The dist directory is where we packed it.

Tree.exe is the file we packed.

5.5 run to view our packaged exe file

Yes, double-click to open it.

5. The meaning of parameters

-F means to generate a single executable file

-w means to remove the console window, which is very useful in the GUI interface. However, if it is a command line program, then delete this option!

-p means that you customize the classpath that needs to be loaded, which is not needed in general.

-I represents the icon of the executable file

6. Christmas tree source file attached

Tree.py

Import turtlescreen = turtle.Screen () screen.setup (375,700) circle = turtle.Turtle () circle.shape ('circle') circle.color (' red') circle.speed ('fastest') circle.up () square = turtle.Turtle () square.shape (' square') square.color ('green') square.speed (' fastest') square.up () circle.goto (0280) circle.stamp () k = 0for i in range (1) 13): y = 30 * i for j in range (I-k): X = 30 * j square.goto (x,-y + 280) square.stamp () square.goto (- x,-y + 280) square.stamp () if I% 4 = 0: X = 30 * (j + 1) circle.goto (- x -y + 280) circle.stamp () circle.goto (x,-y + 280) circle.stamp () k + = 3 if I% 4 = 3: X = 30 * (j + 1) circle.color ('yellow') circle.goto (- x,-y + 280) circle.stamp () circle.goto (x Circle.stamp () square.color ('brown') for i in range (13,17): y = 30 * i for j in range (2): X = 30 * j square.goto (x,-y + 280) square.stamp () square.goto (- x,-y + 280) square.stamp () turtle.up () turtle.goto (- 20) Turtle.write ("Happy Holidays") # here can send your best wishes turtle.hideturtle () turtle.done () Thank you for reading! This is the end of this article on "how to package exe applications with python and how to install PyInstaller". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

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