Go: Python pack notes with Pyinstaller

Source: Internet
Author: User

Transfer from http://www.itoldme.net/archives/1242

In order to distribute Python to a Windows environment that does not have Python installed, it needs to be packaged as an EXE executable file. Now common python packaging tools have Cx_freeze, Pyinstaller and Py2exe, think I first contact Python, it seems only py2exe, and there are a lot of problems time flies, everything really fast. This article describes the use of Pyinstaller packaging.

I. Preparatory work installation PYWIN32

To http://sourceforge.net/projects/pywin32/download PyWin32, this article uses pywin32-219.win-amd64-py2.7, address: http://sourceforge.net /projects/pywin32/files/pywin32/build%20219/pywin32-219.win-amd64-py2.7.exe/download

Download Pyinstaller

Download the Pyinstaller to http://www.pyinstaller.org/and unzip it. This article uses Pyinstaller 2.1.

or use PIP installation to perform pip install Pyinstaller

Download UPX (optional)

To http://upx.sourceforge.net/download UPX, after decompression UPX placed in the Pyinstaller directory, the role of UPX is to generate the EXE shell, reduce the volume.

Two. How to use

CMD switches to the Pyinstaller folder and executes commands such as:

Pyinstaller myscript.py

Of course, you can also add output options to get a better exe executable file, such as:

Python pyinstaller.py--upx-dir-f xxx.py

-F is used to create a standalone executable program,--upx-dir for compressing files.

Attention:

    • Online tutorial Common-x option to enable UPX has expired
    • If Upx.exe has been copied to the Pyinstaller folder, UPX is used by default, and if not, you can use the--UPX-DIR option, such as--upx-dir=upx_dir,--upx-dir=/usr/local/share /
    • If Upx.exe is copied to the Pyinstaller folder, you need to add a parameter if you do not want to use UPX--noupx
Three. Common parameter Introduction

-F for making independent executable programs

--upx-dir using UPX Shell to compress exe files

--noconsole for Windows and Mac OS X for creating programs that do not display console windows

Other

Pyinstaller can be used for packaging multiple platforms, including Windows (32-bit and 64-bit), Linux (32-bit and 64-bit), Mac OS X (32-bit and 64-bit), Experimentall Y Solaris and AIX.

Pyinstaller can also customize ICO files, etc., complete user manual see http://pythonhosted.org/PyInstaller/

Go: Python pack notes with 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.