Python Packaging exe artifact Pyinstaller

Source: Internet
Author: User

Recently, due to project needs, previous Python files need to be edited as EXE for front-end customers to use.

Since the earliest contact is distutils, it is ready to use Distutils and Py2exe collocation for the Python exe, that is, the traditional use of setup.py way to do EXE installation. But the results are not very good, not very satisfactory. And a python package used by Py2exe is mutually exclusive, so long as the package is installed, it cannot be EXE-formatted. Even if the code does not need to import, it will error.

Therefore, can only reluctantly abandon the Py2exe tool. Use Pyinstaller instead. The use of feelings really is dumped py2exe a few streets. The first is the installation,

Pip Install Pyinstaller

Note: The latest version of Pyinstaller is 3.2.1 only supports 2.7-3.5. However, the latest development version is supported for python3.6 in the develop branch of the link below. Since I am using the 3.6 version. So it's been looking for a long time.

Https://github.com/pyinstaller/pyinstaller

Pyinstaller after installation, only the name of the Pyinstaller installation package will be used:

Pyinstaller hello.py

You can package the hello file. The package file is in the Pyinstaller directory. You can modify the saved location by using the--distpath=xxxx parameter.

There are some other parameters this article also directly found the information on the Internet, as follows:

Introduction to Publishing commands
    1. 1

      There are two ways to invoke the publishing process:

      ① calling a script to be published directly using the Pyinstaller application

      ② calling the Pyinstaller-script script in Python and then calling the script to be published

      There is no difference between the two methods, the method ① a few steps, the method ①.

    2. 2

      -w directive

      Directly published EXE app with command-line Debug window, add-w command inside directive can block

    3. 3

      -F directive

      Note the directives are case-sensitive. This is uppercase. Use the-F directive to package your app as a standalone EXE file, or a folder with various DLLs and dependent files

    4. 4

      -P directive

      You can add the path to the Pyinstaller search module later in this instruction. Because there are many modules involved in app packaging. Here you can add the path yourself. But after the author tests, the Site-packages directory can be recognized, do not need to manually add

      Original URL:

      Https://jingyan.baidu.com/article/a378c960b47034b3282830bb.html

Python Packaging exe artifact Pyinstaller

Related Article

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.