Package python project into exe executable file

auto-py-to-exe

Sometimes, I want to package my python program into an executable file. After checking, you can use auto-py-to-exe to solve the problem.

Introduction

Auto-py-to-exe is an open source tool for packaging Python scripts into executable files. It provides a user-friendly graphical interface that enables users to easily select and configure various options to generate executable files.

Using Auto-py-to-exe, you can choose to package an entire Python project or a single Python script. It supports packaging Python scripts into a Windows executable (.exe) or an executable portable format (.exe) that can be run on systems without a Python interpreter.

The point isThis is a graphical interface operation, which is more friendly than other command line operations

Install

pip install auto-py-to-exe -i https://pypi.tuna.tsinghua.edu.cn/simple

Start
Execute in the command line windowauto-py-to-exe will start the packaging program
Insert image description here
It’s really friendly and supports Chinese.

Packaging
Needless to say, these are all visual interface operations.

import argparse


def add(a, b):
    sum = a + b
    print(sum)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Add two numbers")
    parser.add_argument("a", type=int, help="First number")
    parser.add_argument("b", type=int, help="Second number")
    args = parser.parse_args()

    add(args.a, args.b)

Insert image description here
Run
In the project where the executable file is located, open cmd to execute it.
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_41897680/article/details/134214268