Python Cross-platform packaging

Source: Internet
Author: User
Tags python script

For Pyinstaller, you can finish compiling the Python script under Windows,linux, and Mac, and generate the Exe,elf,.app file;

1. method of Use;

In Pyinstaller's official web download, generally is the source package, can be extracted directly after use:

Python pyinstaller.py test.py

A test directory is generated under the Pyinstaller directory and contains the BUID and dist two subdirectories, and the subdirectories dist the executable files;

2. If you need to compile into a single file:

Python pyinstaller.py-f test.py

To generate a single executable file

3. If you need to add a software icon:

Python pyinstaller.py-f test.py-i Test.icon

Note that the icon file must be the only line;

3. If you compile a GUI project, you can use the

Python pyinstaller.py-w test.py

Or:

Python pyinstaller.py-w test.pyw

Or:

Python pyinstaller.py-w--noconsole (under Windwos platform)

Linux default does not have pop-up windows (popup terminal);

4. Compile in a Mac environment with an app executable file.

Python pyinstaller.py test.py-w--windowed

UNIX executables and app files are included in the project directory at this time

5. Compressing the executable file

Use UPX;

UPX support WINDOWS,LINUX32/64 bit;

How to use:

Under Windows: Place the Upx.exe directly under the Pyinstaller directory;

Instructions for use under Linux:
Python pyinstaller.py test.py--upx-dir/home/test/upx/

6.mac Pyinstaller compiler is not stable, you can use Py2app to try.

Through the completion of the project, I realized that the completion of cross-platform software, compatibility is a big problem, in addition, the use of Python completed projects, temporarily compiled into executable files after the file is too large, inefficient execution;

In particular, projects that have been added to the GUI, such as projects that use QT, have been compiled to perform faster and less efficiently than executable files.

Cross-platform projects are best chosen in C or Java, because the existing compilers are very convenient.

Python Cross-platform packaging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.