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

Introduction, installation and usage of py2exe

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

Share

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

This article mainly explains "introduction, installation and usage of py2exe". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the introduction, installation and usage of py2exe.

I. brief introduction

Py2exe is a tool that converts python scripts into stand-alone executable programs (* .exe) on windows so that you can run this executable program on windows systems without installing python. Py2exe has been used to create wxPython,Tkinter,Pmw,PyGTK,pygame,win32com client and server, and other stand-alone programs. Py2exe is released under an open source license.

Application Scheme of Python script in other language Environment

Introduction to the advantages of python scripting language in practical application

Correlation of the five advantages of vim compiler in Python scripts

Code introduction to Python script file LineCount.py

The actual operation of calling each other between Python script and C++ program

Second, install py2exe

Download and run the py2exe version of installer corresponding to the Python you installed, which will install py2exe and the corresponding examples; these examples are installed in the lib\ site-packages\ py2exe\ samples directory.

III. The usage of py2exe

If you have a python script called myscript.py and you want to convert it to an executable program that runs on windows and run on a windows system that does not have python installed, then you should first write a setup script for publishing the program, such as mysetup.py, which inserts the statement import py2exe before the setup function.

An example of mysetup.py is as follows:

# mysetup.py from distutils.core import setup import py2exe setup (console= ["myscript.py"])

Then run mysetup.py as follows:

Python mysetup.py py2exe

The execution of the above command will result in a subdirectory called dist that contains the files myscript.exe,python24.dll,library.zip.

If you use compiled C extension modules in your myscript.py script, these modules will also be copied in a subdirectory. Similarly, all dll files are required at run time, except for the system's dll files.

The files in the dist subdirectory contain what your program needs, and you should publish all the contents of this subdirectory together.

By default, py2exe creates the following required files under the directory dist:

1. One or more exe files.

2 、 python##.dll .

3. Several .pyd files, which are compiled extensions that are required by exe files; plus other .dll files, these .dll are required by .pyd.

4. A library.zip file that contains compiled pure python modules such as .pyc or .pyo

The above mysetup.py creates a console myscript.exe program, and if you want to create a graphical user interface program, you just need to replace console= ["myscript.py"] in mysetup.py with windows= ["myscript.py"]. Py2exe can create multiple exe files at a time, and you need to pass a list of these Python script files to the keyword parameters of console or windows.

This is useful if you have several related scripts. Run the following command, and all command line tags for the py2exe command will be displayed.

At this point, I believe you have a deeper understanding of the introduction, installation and usage of py2exe. You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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